repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/dataloaders/utils.py
import numpy as np import torch def decode_seg_map_sequence(label_masks, dataset='pascal'): rgb_masks = [] for label_mask in label_masks: rgb_mask = decode_segmap(label_mask, dataset) rgb_masks.append(rgb_mask) rgb_masks = torch.from_numpy(np.array(rgb_masks).transpose([0, 3, 1, 2])) re...
3,959
33.137931
84
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/dataloaders/__init__.py
from torch.utils.data import DataLoader, dataset from dataloaders.datasets import combine_dbs, indexed_dataset import numpy as np def make_data_loader(args, proposal_generator=None, **kwargs): def wrap_dataset(set): if 'single_image_training' in args and args.single_image_training is not None: if ar...
2,887
44.84127
113
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/dataloaders/datasets/cityscapes.py
import os import numpy as np import scipy.misc as m from PIL import Image from torch.utils import data from mypath import Path from torchvision import transforms from dataloaders import custom_transforms as tr class CityscapesSegmentation(data.Dataset): NUM_CLASSES = 19 def __init__(self, args, root=Path.db_r...
5,370
35.537415
103
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/dataloaders/datasets/pascal.py
from __future__ import print_function, division import os from PIL import Image import numpy as np import torch from torch.utils.data import Dataset from mypath import Path from torchvision import transforms from dataloaders import custom_transforms as tr class VOCSegmentation(Dataset): """ PascalVoc dataset ...
7,403
33.598131
105
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/dataloaders/datasets/sbd.py
from __future__ import print_function, division import os import numpy as np import scipy.io import torch.utils.data as data from PIL import Image from mypath import Path from torchvision import transforms from dataloaders import custom_transforms as tr class SBDSegmentation(data.Dataset): NUM_CLASSES = 21 ...
4,081
30.643411
106
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/dataloaders/datasets/indexed_dataset.py
import torch.utils.data.dataset class IndexedDataset(torch.utils.data.dataset.Dataset): def __init__(self, base): self.base = base def __getitem__(self, index): sample = self.base[index] sample["index"] = index return sample def __len__(self): return len(self.base)...
321
22
55
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/dataloaders/datasets/combine_dbs.py
import torch.utils.data as data class CombineDBs(data.Dataset): NUM_CLASSES = 21 def __init__(self, dataloaders, excluded=None): self.dataloaders = dataloaders self.excluded = excluded self.im_ids = [] # Combine object lists for dl in dataloaders: for elem ...
3,310
32.11
96
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/dataloaders/datasets/coco.py
import numpy as np import torch from torch.utils.data import Dataset from mypath import Path from tqdm import trange import os from pycocotools.coco import COCO from pycocotools import mask from torchvision import transforms from dataloaders import custom_transforms as tr from PIL import Image, ImageFile ImageFile.LOAD...
5,636
34.012422
96
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/utils/log_lin_softmax.py
import torch from torch.autograd import Function from torch.autograd import Variable import torch.nn.functional as F class LogLinSoftmax(Function): # computes log(a + b * s_ijkl) where s_ijkl is softmax of the input @staticmethod def forward(ctx, a, b, logits, dim): ctx.dim, ctx.a, ctx.b = dim, a...
2,569
31.948718
88
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/utils/proposal_generator.py
import multiprocessing as mp import tempfile, shutil, os import io, pickle import torch import torch.nn.functional as F import gzip class AlphaBasedProposalGenerator(object): def __init__(self, alpha_expansion, eps=0): self.alpha_expansion = alpha_expansion self.model = None self.eps = eps...
3,035
27.373832
84
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/utils/saver.py
import os import shutil import torch from collections import OrderedDict import glob class Saver(object): def __init__(self, args): self.args = args self.directory = os.path.join('run', args.dataset + args.train_dataset_suffix, args.checkname) self.runs = sorted(glob.glob(os.path.join(self...
2,581
39.34375
109
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/utils/vis.py
import torch def get_edges(seg_map): edges = torch.zeros_like(seg_map) == 1 edges[..., :-1, :] |= seg_map[..., :-1, :] != seg_map[..., 1:, :] edges[..., :, :-1] |= seg_map[..., :, :-1] != seg_map[..., :, 1:] edges[..., 1:, :] |= seg_map[..., :-1, :] != seg_map[..., 1:, :] edges[..., :, 1:] |= seg...
378
36.9
69
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/utils/loss.py
import torch import torch.nn as nn import torch.nn.functional as F class SegmentationLosses(object): def __init__(self, weight=None, reduction_mode='mean', batch_average=True, ignore_index=255, cuda=False): self.ignore_index = ignore_index self.weight = weight self.reduction_mode = reductio...
3,977
33.894737
109
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/utils/summaries.py
import os import torch import numpy as np import scipy.ndimage from torchvision.utils import make_grid from tensorboardX import SummaryWriter from dataloaders.utils import decode_seg_map_sequence from utils import vis class TensorboardSummary(object): def __init__(self, directory): self.directory = directo...
1,691
42.384615
108
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/aspp.py
import math import torch import torch.nn as nn import torch.nn.functional as F from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d class _ASPPModule(nn.Module): def __init__(self, inplanes, planes, kernel_size, padding, dilation, BatchNorm): super(_ASPPModule, self).__init__() sel...
3,602
36.926316
116
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/decoder.py
import math import torch import torch.nn as nn import torch.nn.functional as F from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d class Decoder(nn.Module): def __init__(self, num_classes, backbone, BatchNorm, skip=False): super(Decoder, self).__init__() if backbone == 'resnet' or...
3,606
34.019417
104
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/deeplab.py
import torch import torch.nn as nn import torch.nn.functional as F from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d from modeling.aspp import build_aspp from modeling.decoder import build_decoder from modeling.backbone import build_backbone def freeze_batchnorm(self): for m in self.modules():...
2,898
30.857143
93
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/backbone/resnet.py
import math import torch.nn as nn import torch.utils.model_zoo as model_zoo from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d class Bottleneck(nn.Module): expansion = 4 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, BatchNorm=None): super(Bottleneck, se...
6,222
37.41358
130
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/backbone/drn.py
import torch.nn as nn import math import torch.utils.model_zoo as model_zoo from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d webroot = 'https://tigress-web.princeton.edu/~fy/drn/models/' model_urls = { 'resnet50': 'https://download.pytorch.org/models/resnet50-19c8e357.pth', 'drn-c-26': we...
14,649
35.352357
100
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/backbone/xception.py
import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d def fixed_padding(inputs, kernel_size, dilation): kernel_size_effective = kernel_size + (kernel_size - 1) * (dilation - 1) ...
11,553
39.118056
116
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/backbone/mobilenet.py
import torch import torch.nn.functional as F import torch.nn as nn import math from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d import torch.utils.model_zoo as model_zoo def conv_bn(inp, oup, stride, BatchNorm): return nn.Sequential( nn.Conv2d(inp, oup, 3, stride, 1, bias=False), ...
5,390
34.467105
110
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/sync_batchnorm/replicate.py
# -*- coding: utf-8 -*- # File : replicate.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import functools from torch.nn.parallel.dat...
3,218
35.579545
115
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/sync_batchnorm/unittest.py
# -*- coding: utf-8 -*- # File : unittest.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import unittest import numpy as np from torc...
834
26.833333
157
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/modeling/sync_batchnorm/batchnorm.py
# -*- coding: utf-8 -*- # File : batchnorm.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import collections import torch import torc...
12,932
44.861702
116
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/doc/deeplab_resnet.py
import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d BatchNorm2d = SynchronizedBatchNorm2d class Bottleneck(nn.Module): expansion = 4 def __init__(self, inplanes, planes, ...
11,247
34.594937
111
py
robust_trust_region
robust_trust_region-main/pytorch-deeplab_v3_plus/doc/deeplab_xception.py
import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d BatchNorm2d = SynchronizedBatchNorm2d class SeparableConv2d(nn.Module): def __init__(self, inplanes, planes, kernel_size=3,...
16,199
37.117647
127
py
fat-albert
fat-albert-master/abmn/src/core/model.py
import re import tensorflow as tf initializer = "xavier" def _activation_summary(x): tensor_name = re.sub('%s_[0-9]*/', x.op.name) tf.compat.v1.summary.histogram(tensor_name + '/activations', x) tf.compat.v1.summary.scalar(tensor_name + '/sparsity', tf.nn.zero_fraction(x)) # Dropou...
10,768
38.16
127
py
fat-albert
fat-albert-master/bert/setup.py
""" Simple check list from AllenNLP repo: https://github.com/allenai/allennlp/blob/master/setup.py To create the package for pypi. 1. Change the version in __init__.py, setup.py as well as docs/source/conf.py. 2. Commit these changes with the message: "Release: VERSION" 3. Add a tag in git to mark the release: "git...
2,923
39.054795
183
py
fat-albert
fat-albert-master/bert/hubconf.py
from transformers import ( AutoTokenizer, AutoConfig, AutoModel, AutoModelWithLMHead, AutoModelForSequenceClassification, AutoModelForQuestionAnswering ) from transformers.file_utils import add_start_docstrings dependencies = ['torch', 'tqdm', 'boto3', 'requests', 'regex', 'sentencepiece', 'sacremoses'] @add_star...
6,489
56.433628
189
py
fat-albert
fat-albert-master/bert/examples/run_lm_finetuning.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
28,924
50.929982
165
py
fat-albert
fat-albert-master/bert/examples/run_squad.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
31,780
54.175347
151
py
fat-albert
fat-albert-master/bert/examples/run_glue.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
28,343
52.278195
158
py
fat-albert
fat-albert-master/bert/examples/benchmarks.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.a...
23,631
48.439331
138
py
fat-albert
fat-albert-master/bert/examples/run_summarization_finetuning.py
# coding=utf-8 # Copyright 2019 The HuggingFace Inc. team. # Copyright (c) 2019 The HuggingFace Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.a...
15,727
30.902637
120
py
fat-albert
fat-albert-master/bert/examples/run_bertology.py
#!/usr/bin/env python3 # Copyright 2018 CMU and The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requir...
18,901
51.798883
177
py
fat-albert
fat-albert-master/bert/examples/utils_summarization_test.py
# coding=utf-8 # Copyright 2019 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
5,178
36.80292
98
py
fat-albert
fat-albert-master/bert/examples/run_generation.py
#!/usr/bin/env python3 # coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in c...
13,112
49.241379
167
py
fat-albert
fat-albert-master/bert/examples/run_ner.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
28,788
53.013133
184
py
fat-albert
fat-albert-master/bert/examples/utils_summarization.py
from collections import deque import os import torch from torch.utils.data import Dataset # ------------ # Data loading # ------------ class CNNDailyMailDataset(Dataset): """ Abstracts the dataset used to train seq2seq models. CNN/Daily News: The CNN/Daily News raw datasets are downloaded from [1]. T...
6,022
31.556757
88
py
fat-albert
fat-albert-master/bert/examples/run_tf_glue.py
import os import tensorflow as tf import tensorflow_datasets from transformers import BertTokenizer, TFBertForSequenceClassification, BertConfig, glue_convert_examples_to_features, BertForSequenceClassification, glue_processors # script parameters BATCH_SIZE = 32 EVAL_BATCH_SIZE = BATCH_SIZE * 2 USE_XLA = False USE_AM...
3,978
41.329787
166
py
fat-albert
fat-albert-master/bert/examples/run_multiple_choice.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
29,481
50.722807
168
py
fat-albert
fat-albert-master/bert/examples/run_xnli.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
27,117
51.554264
151
py
fat-albert
fat-albert-master/bert/examples/contrib/run_transfo_xl.py
# coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the Lice...
6,742
42.785714
111
py
fat-albert
fat-albert-master/bert/examples/contrib/run_swag.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
31,683
45.731563
154
py
fat-albert
fat-albert-master/bert/examples/contrib/run_movieqa.bak.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
32,036
45.701166
154
py
fat-albert
fat-albert-master/bert/examples/contrib/run_openai_gpt.py
# coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the Lice...
14,471
48.731959
132
py
fat-albert
fat-albert-master/bert/examples/contrib/run_movieqa.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
35,214
45.274639
154
py
fat-albert
fat-albert-master/bert/examples/contrib/run_camembert.py
from pathlib import Path import tarfile import urllib.request import torch from transformers.tokenization_camembert import CamembertTokenizer from transformers.modeling_camembert import CamembertForMaskedLM def fill_mask(masked_input, model, tokenizer, topk=5): # Adapted from https://github.com/pytorch/fairseq/...
2,015
40.142857
114
py
fat-albert
fat-albert-master/bert/examples/distillation/grouped_batch_sampler.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team and Facebook, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
4,368
40.216981
125
py
fat-albert
fat-albert-master/bert/examples/distillation/utils.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team and Facebook, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
4,308
32.146154
104
py
fat-albert
fat-albert-master/bert/examples/distillation/lm_seqs_dataset.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team and Facebook, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
5,453
34.881579
111
py
fat-albert
fat-albert-master/bert/examples/distillation/run_squad_w_distillation.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
33,733
55.129784
151
py
fat-albert
fat-albert-master/bert/examples/distillation/train.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
13,598
45.731959
135
py
fat-albert
fat-albert-master/bert/examples/distillation/distiller.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team and Facebook, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
25,933
46.848708
163
py
fat-albert
fat-albert-master/bert/examples/distillation/scripts/extract.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
4,326
47.077778
158
py
fat-albert
fat-albert-master/bert/examples/distillation/scripts/extract_distilbert.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
4,255
50.277108
158
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/modeling_xxx.py
# coding=utf-8 # Copyright 2018 XXX Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed ...
34,579
51.473445
151
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/convert_xxx_original_tf_checkpoint_to_pytorch.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
2,565
37.878788
100
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/modeling_tf_xxx.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
27,575
53.605941
193
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_model/tests/modeling_xxx_test.py
# coding=utf-8 # Copyright 2018 XXX Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed...
11,628
44.425781
160
py
fat-albert
fat-albert-master/bert/templates/adding_a_new_example_script/run_xxx.py
# coding=utf-8 # Copyright 2018 XXX. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
30,654
53.741071
151
py
fat-albert
fat-albert-master/bert/datasets/SWAG/pytorch_misc.py
""" Miscellaneous functions that might be useful for pytorch """ import h5py import numpy as np import torch from torch.autograd import Variable import os import dill as pkl from itertools import tee from torch import nn import time def optimistic_restore(network, state_dict): mismatch = False own_state = net...
15,621
29.216634
118
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/unarylstm/lstm_swag.py
from typing import Dict, List, TextIO, Optional from overrides import overrides import torch from torch.nn.modules import Linear, Dropout import torch.nn.functional as F from allennlp.common import Params from allennlp.common.checks import check_dimensions_match from allennlp.data import Vocabulary from allennlp.modu...
6,737
45.791667
97
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/esim/esim_swag.py
# TODO: projection dropout with ELMO # l2 reg with ELMO # multiple ELMO layers # doc from typing import Dict, Optional import torch from torch.autograd import Variable from allennlp.common import Params from allennlp.common.checks import check_dimensions_match from allennlp.data import Vocabulary from allennlp...
13,868
45.69697
156
py
fat-albert
fat-albert-master/bert/datasets/SWAG/swag_baselines/decomposable_attention/decomposable_attention_swag.py
from typing import Dict, Optional import torch from allennlp.common import Params from allennlp.common.checks import check_dimensions_match from allennlp.data import Vocabulary from allennlp.models.model import Model from allennlp.modules import FeedForward, MatrixAttention from allennlp.modules import Seq2SeqEncoder...
13,628
50.430189
164
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/rebalance_dataset_mlp.py
""" The big idea will be to add in the worst scoring one. But we want to use a MULTILAYER PERCEPTRON. Also not using word features for now """ import matplotlib as mpl mpl.use('Agg') import seaborn as sns import matplotlib.pyplot as plt from allennlp.data import Vocabulary from torch.nn import functional as F from t...
10,256
39.066406
138
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/classifiers.py
""" The big idea will be to add in the worst scoring one. But we want to use a MULTILAYER PERCEPTRON. Also not using word features for now """ import torch from allennlp.common import Params from allennlp.modules.augmented_lstm import AugmentedLstm from allennlp.modules.seq2seq_encoders.pytorch_seq2seq_wrapper import...
15,626
43.019718
151
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/sample_candidates.py
import pickle as pkl from argparse import ArgumentParser from copy import deepcopy from time import time import numpy as np import pandas as pd import torch from allennlp.commands.predict import Predictor from allennlp.data import Vocabulary from allennlp.models.archival import load_archive from tqdm import tqdm from...
8,718
40.918269
119
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/generate_candidates/rebalance_dataset_ensemble.py
""" The big idea will be to add in the worst scoring one. But we want to use a MULTILAYER PERCEPTRON. Also not using word features for now """ import pickle as pkl from argparse import ArgumentParser from copy import deepcopy import numpy as np import pandas as pd import spacy import torch from allennlp.data import ...
13,160
44.539792
122
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/pretrain_lm.py
import os import pandas as pd import torch from allennlp.data import Instance from allennlp.data import Token from allennlp.data import Vocabulary from allennlp.data.dataset import Batch from allennlp.data.fields import TextField from allennlp.data.token_indexers import SingleIdTokenIndexer from allennlp.data.token_in...
4,759
40.391304
118
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/train_lm.py
import os from argparse import ArgumentParser import numpy as np import pandas as pd import torch from torch import optim from torch.optim.lr_scheduler import StepLR from tqdm import tqdm from create_swag.lm.config import NUM_FOLDS from create_swag.lm.load_data import load_lm_data, RawPassages from create_swag.lm.sim...
3,709
41.159091
104
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/simple_bilm.py
""" A wrapper around ai2s elmo LM to allow for an lm objective... """ from typing import Optional, Tuple from typing import Union, List, Dict import numpy as np import torch from allennlp.common.checks import ConfigurationError from allennlp.data import Token, Vocabulary, Instance from allennlp.data.dataset import Ba...
16,902
48.568915
117
py
fat-albert
fat-albert-master/bert/datasets/SWAG/create_swag/lm/load_data.py
# First make the vocabulary, etc. import os import pickle as pkl import random import simplejson as json from allennlp.common.util import get_spacy_model from allennlp.data import Instance from allennlp.data import Token from allennlp.data import Vocabulary from allennlp.data.dataset import Batch from allennlp.data.f...
6,285
40.629139
118
py
fat-albert
fat-albert-master/bert/transformers/modeling_encoder_decoder.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
15,827
49.893891
472
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_albert.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License...
39,735
48.732165
193
py
fat-albert
fat-albert-master/bert/transformers/optimization.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICEN...
7,658
44.052941
134
py
fat-albert
fat-albert-master/bert/transformers/__main__.py
# coding: utf8 def main(): import sys if (len(sys.argv) < 4 or len(sys.argv) > 6) or sys.argv[1] not in ["bert", "gpt", "transfo_xl", "gpt2", "xlnet", "xlm"]: print( "This command line utility let you convert original (author released) model checkpoint to pytorch.\n" "It should be used a...
7,085
53.507692
135
py
fat-albert
fat-albert-master/bert/transformers/configuration_utils.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
11,152
51.116822
296
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_pytorch_utils.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
12,465
41.546075
166
py
fat-albert
fat-albert-master/bert/transformers/modeling_distilbert.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language Team and Facebook, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
39,603
49.839538
201
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_gpt2.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License...
32,228
49.834385
193
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_transfo_xl.py
# coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the Lice...
36,425
45.820051
193
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_auto.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
37,420
70.687739
472
py
fat-albert
fat-albert-master/bert/transformers/modeling_utils.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
45,511
51.798144
472
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_openai.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License...
30,118
49.535235
193
py
fat-albert
fat-albert-master/bert/transformers/modeling_bert.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
68,217
52.212168
187
py
fat-albert
fat-albert-master/bert/transformers/modeling_gpt2.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License...
34,421
49.920118
148
py
fat-albert
fat-albert-master/bert/transformers/convert_albert_original_tf_checkpoint_to_pytorch.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
2,597
37.776119
103
py
fat-albert
fat-albert-master/bert/transformers/modeling_openai.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License...
31,203
48.687898
148
py
fat-albert
fat-albert-master/bert/transformers/convert_gpt2_original_tf_checkpoint_to_pytorch.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
3,074
39.460526
111
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_roberta.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
22,329
51.789598
193
py
fat-albert
fat-albert-master/bert/transformers/convert_roberta_original_pytorch_checkpoint_to_pytorch.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
8,486
45.889503
188
py
fat-albert
fat-albert-master/bert/transformers/tokenization_bert.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICEN...
22,451
43.636183
183
py
fat-albert
fat-albert-master/bert/transformers/convert_transfo_xl_original_tf_checkpoint_to_pytorch.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
5,518
45.771186
121
py
fat-albert
fat-albert-master/bert/transformers/configuration_ctrl.py
# coding=utf-8 # Copyright 2018 Salesforce and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # htt...
5,775
39.111111
120
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_transfo_xl_utilities.py
# coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the Lice...
8,325
46.306818
110
py
fat-albert
fat-albert-master/bert/transformers/modeling_tf_xlnet.py
# coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the Lice...
57,790
50.92363
193
py
fat-albert
fat-albert-master/bert/transformers/convert_openai_original_tf_checkpoint_to_pytorch.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
3,161
40.605263
118
py
fat-albert
fat-albert-master/bert/transformers/modeling_camembert.py
# coding=utf-8 # Copyright 2019 Inria, Facebook AI Research and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the...
17,760
59.411565
217
py
fat-albert
fat-albert-master/bert/transformers/convert_xlm_original_pytorch_checkpoint_to_pytorch.py
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
3,235
37.52381
117
py