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
bert-nmt
bert-nmt-master/fairseq/binarizer.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from collections import Counter im...
3,090
36.695122
104
py
bert-nmt
bert-nmt-master/fairseq/distributed_utils.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from collections import namedtuple...
6,562
35.461111
97
py
bert-nmt
bert-nmt-master/fairseq/sequence_generator.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch from fa...
29,187
43.493902
142
py
bert-nmt
bert-nmt-master/fairseq/legacy_distributed_data_parallel.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ A modified version of the lega...
6,450
36.289017
88
py
bert-nmt
bert-nmt-master/fairseq/options.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import argparse import torch impo...
24,932
51.161088
114
py
bert-nmt
bert-nmt-master/fairseq/bleu.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import ctypes import math import t...
4,063
29.787879
83
py
bert-nmt
bert-nmt-master/fairseq/file_utils.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ Utilities for working with the...
12,275
34.582609
127
py
bert-nmt
bert-nmt-master/fairseq/search.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch class ...
8,917
35.105263
104
py
bert-nmt
bert-nmt-master/fairseq/trainer.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ Train a network across multipl...
20,283
39.406375
126
py
bert-nmt
bert-nmt-master/fairseq/sequence_generator_ensemble.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch from fa...
29,416
43.503782
142
py
bert-nmt
bert-nmt-master/fairseq/modules/transformer_sentence_encoder_layer.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import torch.nn as nn...
3,030
30.905263
80
py
bert-nmt
bert-nmt-master/fairseq/modules/learned_positional_embedding.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.nn as nn from fairse...
1,894
35.442308
88
py
bert-nmt
bert-nmt-master/fairseq/modules/multihead_attention.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch from torch import nn ...
12,130
39.302326
114
py
bert-nmt
bert-nmt-master/fairseq/modules/highway.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch from torch import nn...
1,853
32.709091
97
py
bert-nmt
bert-nmt-master/fairseq/modules/linearized_convolution.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import torch.nn.funct...
3,686
39.966667
95
py
bert-nmt
bert-nmt-master/fairseq/modules/downsampled_multihead_attention.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. # import math import torch import...
9,923
37.316602
106
py
bert-nmt
bert-nmt-master/fairseq/modules/gelu.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ See "Gaussian Error Linear Unit...
777
30.12
90
py
bert-nmt
bert-nmt-master/fairseq/modules/positional_embedding.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.nn as nn from .learn...
1,395
37.777778
83
py
bert-nmt
bert-nmt-master/fairseq/modules/adaptive_input.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch from torch import nn...
2,391
30.893333
80
py
bert-nmt
bert-nmt-master/fairseq/modules/character_token_embedder.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import torch.nn.funct...
5,406
32.583851
106
py
bert-nmt
bert-nmt-master/fairseq/modules/unfold.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.nn.functional as F ...
678
32.95
91
py
bert-nmt
bert-nmt-master/fairseq/modules/adaptive_softmax.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import operator import functools ...
7,315
34.004785
112
py
bert-nmt
bert-nmt-master/fairseq/modules/conv_tbc.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch from torch.nn.modules...
1,464
36.564103
90
py
bert-nmt
bert-nmt-master/fairseq/modules/mean_pool_gating_network.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import torch.nn.funct...
2,159
39
84
py
bert-nmt
bert-nmt-master/fairseq/modules/logsumexp_moe.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch class LogSumExpMoE(...
943
31.551724
78
py
bert-nmt
bert-nmt-master/fairseq/modules/beamable_mm.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import torch.nn as nn...
1,887
36.76
80
py
bert-nmt
bert-nmt-master/fairseq/modules/layer_norm.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch def LayerNorm(norma...
698
35.789474
81
py
bert-nmt
bert-nmt-master/fairseq/modules/scalar_bias.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. # import torch class ScalarBias(...
996
28.323529
78
py
bert-nmt
bert-nmt-master/fairseq/modules/transformer_sentence_encoder.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from typing import Tuple, Optional...
7,317
33.037209
84
py
bert-nmt
bert-nmt-master/fairseq/modules/grad_multiply.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch class GradMultiply(...
550
25.238095
78
py
bert-nmt
bert-nmt-master/fairseq/modules/sinusoidal_positional_embedding.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch import t...
3,627
40.227273
105
py
bert-nmt
bert-nmt-master/fairseq/modules/lightweight_convolution.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import torch.nn as nn...
9,506
38.6125
103
py
bert-nmt
bert-nmt-master/fairseq/modules/dynamic_convolution.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import torch.nn as nn...
10,037
43.026316
132
py
bert-nmt
bert-nmt-master/fairseq/criterions/fairseq_criterion.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from torch.nn.modules.loss import ...
1,394
29.326087
78
py
bert-nmt
bert-nmt-master/fairseq/criterions/adaptive_loss.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch.nn.funct...
3,631
37.231579
105
py
bert-nmt
bert-nmt-master/fairseq/criterions/cross_entropy.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch.nn.functi...
2,616
36.927536
95
py
bert-nmt
bert-nmt-master/fairseq/criterions/masked_lm_loss.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch import t...
6,356
41.38
81
py
bert-nmt
bert-nmt-master/fairseq/criterions/composite_loss.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from torch import nn from fairseq...
3,494
36.180851
96
py
bert-nmt
bert-nmt-master/fairseq/models/lstm.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import torch.nn as nn...
24,290
43.005435
103
py
bert-nmt
bert-nmt-master/fairseq/models/masked_lm.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import torch.nn as nn...
15,443
42.382022
100
py
bert-nmt
bert-nmt-master/fairseq/models/fairseq_encoder.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.nn as nn class Fair...
1,504
30.354167
78
py
bert-nmt
bert-nmt-master/fairseq/models/fconv.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch import to...
27,135
40.492355
114
py
bert-nmt
bert-nmt-master/fairseq/models/lightconv.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch import t...
34,360
44.152431
125
py
bert-nmt
bert-nmt-master/fairseq/models/transformer.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch import t...
98,189
45.055347
140
py
bert-nmt
bert-nmt-master/fairseq/models/fconv_self_att.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch import t...
23,106
40.48474
111
py
bert-nmt
bert-nmt-master/fairseq/models/fairseq_decoder.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.nn as nn from fairse...
2,951
34.142857
95
py
bert-nmt
bert-nmt-master/fairseq/models/fairseq_model.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ Base classes for various fairse...
17,271
35.985011
140
py
bert-nmt
bert-nmt-master/fairseq/models/distributed_fairseq_model.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import inspect from torch.nn impo...
2,546
35.913043
82
py
bert-nmt
bert-nmt-master/fairseq/optim/nag.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch from torch.optim.opti...
3,326
32.606061
96
py
bert-nmt
bert-nmt-master/fairseq/optim/sgd.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.optim from . import ...
1,475
34.142857
92
py
bert-nmt
bert-nmt-master/fairseq/optim/fp16_optimizer.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch from fairseq import ...
13,279
36.514124
97
py
bert-nmt
bert-nmt-master/fairseq/optim/adam.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import types import t...
13,323
41.56869
139
py
bert-nmt
bert-nmt-master/fairseq/optim/adafactor.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch import to...
9,602
43.665116
110
py
bert-nmt
bert-nmt-master/fairseq/optim/adagrad.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.optim from . import ...
1,311
32.641026
92
py
bert-nmt
bert-nmt-master/fairseq/optim/fairseq_optimizer.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import torch class ...
3,610
33.390476
99
py
bert-nmt
bert-nmt-master/fairseq/optim/adadelta.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.optim from . import ...
1,868
39.630435
105
py
bert-nmt
bert-nmt-master/fairseq/optim/lamb.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ LAMB optimizer from github.com/...
5,862
38.884354
109
py
bert-nmt
bert-nmt-master/fairseq/optim/lr_scheduler/inverse_square_root_schedule.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from . import FairseqLRScheduler, ...
3,026
38.828947
97
py
bert-nmt
bert-nmt-master/fairseq/optim/lr_scheduler/reduce_lr_on_plateau.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.optim.lr_scheduler f...
2,337
38.627119
90
py
bert-nmt
bert-nmt-master/fairseq/optim/lr_scheduler/cosine_lr_scheduler.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math from . import Fairseq...
4,867
39.231405
105
py
bert-nmt
bert-nmt-master/fairseq/data/language_pair_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import numpy as np import torch f...
9,840
41.786957
117
py
bert-nmt
bert-nmt-master/fairseq/data/token_block_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import numpy as np im...
6,411
39.582278
101
py
bert-nmt
bert-nmt-master/fairseq/data/block_pair_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import numpy as np im...
12,975
40.193651
99
py
bert-nmt
bert-nmt-master/fairseq/data/dictionary.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from collections import Counter fr...
10,544
33.460784
109
py
bert-nmt
bert-nmt-master/fairseq/data/masked_lm_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math import numpy as np im...
12,558
37.643077
83
py
bert-nmt
bert-nmt-master/fairseq/data/lm_context_window_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import numpy as np import torch f...
3,018
36.271605
90
py
bert-nmt
bert-nmt-master/fairseq/data/iterators.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import itertools import math impo...
8,973
32.864151
91
py
bert-nmt
bert-nmt-master/fairseq/data/backtranslation_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch from fairseq import ...
6,343
36.761905
93
py
bert-nmt
bert-nmt-master/fairseq/data/monolingual_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import numpy as np import torch f...
7,577
36.330049
117
py
bert-nmt
bert-nmt-master/fairseq/data/indexed_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import os import shutil import str...
14,793
29.756757
115
py
bert-nmt
bert-nmt-master/fairseq/data/noising.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import numpy as np f...
12,285
37.63522
110
py
bert-nmt
bert-nmt-master/fairseq/data/fairseq_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch.utils.data class Fa...
1,652
29.611111
80
py
bert-nmt
bert-nmt-master/fairseq/data/transform_eos_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch from . import Fairse...
4,408
35.741667
88
py
bert-nmt
bert-nmt-master/fairseq/tasks/language_modeling.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import itertools import os import...
9,622
38.438525
117
py
bert-nmt
bert-nmt-master/fairseq/tasks/multilingual_translation.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from collections import OrderedDic...
15,605
43.209632
113
py
bert-nmt
bert-nmt-master/fairseq/tasks/translation_moe.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import contextlib import torch ...
9,130
40.316742
110
py
bert-nmt
bert-nmt-master/fairseq/tasks/fairseq_task.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch from fairseq import ...
10,256
36.434307
104
py
bert-nmt
bert-nmt-master/bert/tokenization.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...
17,894
39.763098
135
py
bert-nmt
bert-nmt-master/bert/modeling.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 co...
60,510
48.235964
171
py
bert-nmt
bert-nmt-master/bert/file_utils.py
""" Utilities for working with the local dataset cache. This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp Copyright by the AllenNLP authors. """ from __future__ import (absolute_import, division, print_function, unicode_literals) import sys import json import logging import os impor...
9,347
32.385714
98
py
grad-cam-text
grad-cam-text-master/dataset-ko.py
import gensim.models as word2vec from konlpy.tag import Mecab import jamotools import tensorflow as tf import numpy as np from dataset import Word2vecEmbedder, Dataset class Word2vecKoMorphEmbedder(Word2vecEmbedder): def __init__(self): model = word2vec.Word2Vec.load('./word2vec/word2vec_news_morph_300.mod...
3,012
34.034884
130
py
grad-cam-text
grad-cam-text-master/dataset.py
import gensim.models as word2vec import tensorflow as tf import numpy as np class Word2vecEmbedder(): def __init__(self, model, max_vocab_size, embedding_dim): self.w2v = model self.max_vocab_size = max_vocab_size self.embedding_dim = embedding_dim self._build() def _build(self...
4,973
41.152542
160
py
GNS-Modeling
GNS-Modeling-master/gns/viz/gmm.py
import sys if 'matplotlib' not in sys.modules: import matplotlib as mpl mpl.use('Agg') from matplotlib import transforms from matplotlib.patches import Ellipse from matplotlib.colors import Normalize import matplotlib.pyplot as plt import numpy as np import torch from .general import get_color from ..mixnet.lo...
4,810
31.727891
100
py
GNS-Modeling
GNS-Modeling-master/gns/viz/strokes.py
import numpy as np import torch from pybpl.util.stroke import dist_along_traj from ..utils import torch_to_numpy, traj_from_spline from .general import get_color def space_motor_to_img(x): x = torch_to_numpy(x) x = np.copy(x) x[:,1] = -x[:,1] return x def add_arrow(line, size=15, **kwargs): col...
2,153
31.149254
74
py
GNS-Modeling
GNS-Modeling-master/gns/token/model.py
import torch import torch.nn as nn import torch.distributions as dist from pybpl.util import apply_warp class TokenModel(nn.Module): def __init__(self, shape_noise=True, loc_noise=True, affine_noise=True): super().__init__() # control points noise self.register_buffer('mu_shape', torch.te...
5,148
32.219355
86
py
GNS-Modeling
GNS-Modeling-master/gns/mixnet/losses.py
import math import torch import torch.nn as nn import torch.utils.data from torch.distributions import Normal, Independent, MultivariateNormal from ..utils.nn import apply_mask def mvn_full(x, means, covs): x = x.unsqueeze(-2) # (...,1,d) mvn_logprobs = MultivariateNormal(means, covs).log_prob(x) # (...,k) ...
2,913
27.851485
87
py
GNS-Modeling
GNS-Modeling-master/gns/mixnet/sampling.py
import math import torch from torch.distributions import Normal, Independent, MultivariateNormal from torch.distributions import Categorical def sample_xy_diag(mix_probs, means, scales): # get MVN means and scales mixtures = Categorical(mix_probs).sample() # (n,) means_sel = torch.stack([elt[i] for elt, i...
1,856
28.015625
82
py
GNS-Modeling
GNS-Modeling-master/gns/omniglot/minimal_splines.py
import torch from pybpl.splines import fit_bspline_to_traj def fit_minimal_spline(stroke, thresh, max_nland=100, normalize=True): assert isinstance(stroke, torch.Tensor) ntraj = stroke.size(0) # determine num control points for nland in range(1, min(ntraj+1, max_nland)): spline, residuals = f...
546
29.388889
82
py
GNS-Modeling
GNS-Modeling-master/gns/type/location_model.py
import torch import torch.nn as nn import torch.nn.functional as F from ..utils.mvn import tikhonov, compute_cov2d, gauss_norm_to_orig from ..mixnet.losses import gmm_losses from ..mixnet.sampling import sample_xy_full, adjust_gmm def conv_block(in_channels, out_channels, dropout=0.): block = nn.Sequential( ...
5,513
30.508571
88
py
GNS-Modeling
GNS-Modeling-master/gns/type/model.py
import os import math import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.utils.rnn as rnn from pybpl.splines import get_stk_from_bspline from .. import MODEL_SAVE_PATH from ..rendering import Renderer from .terminate_model import CNNTerminate from .location_model import CNNStart from .s...
8,892
38.176211
99
py
GNS-Modeling
GNS-Modeling-master/gns/type/stroke_model.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions import Bernoulli from ..utils.mvn import tikhonov, compute_cov2d, gauss_norm_to_orig from ..mixnet.losses import gmm_losses_seq, end_losses_seq from ..mixnet.sampling import sample_xy_full, adjust_gmm, adjust_bernoulli class...
14,780
31.202614
84
py
GNS-Modeling
GNS-Modeling-master/gns/type/terminate_model.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions import Bernoulli from ..mixnet.sampling import adjust_bernoulli class ConvBlock(nn.Module): def __init__(self, in_channels, out_channels, dropout=0.): super().__init__() self.conv = nn.Conv2d(in_channels,...
3,837
29.220472
88
py
GNS-Modeling
GNS-Modeling-master/gns/rendering/renderer.py
import torch import torch.nn as nn import torch.nn.functional as F from pybpl.parameters import Parameters from pybpl.util.general import fspecial def drawings_to_cpu(drawings): if isinstance(drawings[0], list): if drawings[0][0].is_cuda: drawings = [[stk.cpu() for stk in drawing] for drawing...
9,661
30.575163
85
py
GNS-Modeling
GNS-Modeling-master/gns/utils/mvn.py
import numpy as np import torch def set_triu(R, corrs): d = R.size(-1) x_ix, y_ix = np.triu_indices(d, 1) ix = np.stack([x_ix, y_ix]) ix = torch.from_numpy(ix) R[...,ix[0],ix[1]] = corrs # (n,d,d) def set_tril(R, corrs): d = R.size(-1) x_ix, y_ix = np.tril_indices(d, -1) ix = np.stack...
1,676
21.662162
66
py
GNS-Modeling
GNS-Modeling-master/gns/utils/nn.py
import torch import torch.nn as nn def load_submodule(f, submod_name, cpu=False): if cpu: mod_state_dict = torch.load(f, map_location='cpu') else: mod_state_dict = torch.load(f) submod_state_dict = {} for mod_key,val in mod_state_dict.items(): if mod_key.startswith(submod_name)...
3,092
29.323529
81
py
GNS-Modeling
GNS-Modeling-master/gns/utils/hausdorff.py
""" Taken from Omniglot repo: https://github.com/brendenlake/omniglot/blob/9afc3137708d2c6e7b780ce3ed545492fcc873e3/python/one-shot-classification/demo_classification.py """ from tqdm import tqdm import numpy as np import torch import torch.nn.functional as F from scipy.spatial.distance import cdist from . import para...
3,307
25.894309
139
py
GNS-Modeling
GNS-Modeling-master/gns/utils/general.py
import sys import multiprocessing as mp import numpy as np if 'matplotlib' not in sys.modules: import matplotlib as mpl mpl.use('Agg') import matplotlib.pyplot as plt import torch from pybpl.splines import get_stk_from_bspline from pybpl.rendering import render_image from pybpl.parameters import Parameters de...
2,737
23.446429
82
py
GNS-Modeling
GNS-Modeling-master/gns/inference/parsing/top_k.py
import warnings import math import itertools import numpy as np import torch from pybpl.data import unif_space from pybpl.matlab.bottomup import generate_random_parses from ...omniglot.minimal_splines import fit_minimal_spline from .util import sample_from_generator def process_parse(parse, device=None): parse_...
3,189
35.666667
89
py
GNS-Modeling
GNS-Modeling-master/gns/inference/viz/opt_progress_token.py
import sys if 'matplotlib' not in sys.modules: import matplotlib as mpl mpl.use('Agg') import matplotlib.pyplot as plt import torch from pybpl.util.stroke import dist_along_traj from pybpl.util.affine import apply_warp from pybpl.splines import get_stk_from_bspline from ...viz import get_color, plot_image, plo...
2,796
35.324675
85
py
GNS-Modeling
GNS-Modeling-master/gns/inference/viz/util.py
import numpy as np import torch def get_loss_limits(losses, pct=90): if torch.is_tensor(losses): losses = losses.numpy() losses = losses.flatten() vmax = np.percentile(losses, pct) vmin = np.min(losses) vmean = (vmax+vmin)/2 vmin = vmean - 1.5*(vmax-vmin)/2 vmax = vmean + 1.5*(vma...
507
24.4
53
py