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
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/bert/model_training_utils.py
# Copyright 2019 The TensorFlow Authors. 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 applica...
17,136
39.03972
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/bert/modeling.py
# Copyright 2019 The TensorFlow Authors. 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 applica...
39,139
36.240723
93
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/bert/bert_models.py
# Copyright 2019 The TensorFlow Authors. 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 applica...
16,982
38.131336
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/bert/embedding_layer.py
# Copyright 2018 The TensorFlow Authors. 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 applica...
4,001
36.401869
81
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/bert/run_pretraining.py
# Copyright 2019 The TensorFlow Authors. 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 applica...
7,510
35.461165
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/bert/model_saving_utils.py
# Copyright 2019 The TensorFlow Authors. 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 applica...
4,416
37.745614
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/bert/benchmark/bert_benchmark.py
# Copyright 2019 The TensorFlow Authors. 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 applica...
11,596
36.898693
109
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/bert/benchmark/benchmark_utils.py
# Copyright 2019 The TensorFlow Authors. 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 applica...
4,024
31.723577
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/bert/benchmark/bert_squad_benchmark.py
# Copyright 2019 The TensorFlow Authors. 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 applica...
12,048
32.7507
109
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/utils/logs/hooks_helper_test.py
# Copyright 2017 The TensorFlow Authors. 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 applica...
2,704
35.554054
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/utils/logs/logger_test.py
# Copyright 2018 The TensorFlow Authors. 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 applica...
14,791
39.195652
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/utils/misc/model_helpers_test.py
# Copyright 2018 The TensorFlow Authors. 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 applica...
4,911
37.375
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/utils/misc/keras_utils.py
# Copyright 2018 The TensorFlow Authors. 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 applica...
7,832
36.3
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/utils/flags/_performance.py
# Copyright 2018 The TensorFlow Authors. 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 applica...
12,433
41.728522
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/official/utils/data/file_io_test.py
# Copyright 2018 The TensorFlow Authors. 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 applica...
6,358
30.795
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/modules/from_parlai.py
import tensorflow as tf import re import requests import os import zipfile re_art = re.compile(r'\b(a|an|the)\b') re_punc = re.compile(r'[!"#$%&()*+,-./:;<=>?@\[\]\\^`{|}~_\']') def normalize_answer(s): """Lower text and remove punctuation, articles and extra whitespace.""" def remove_articles(text): ...
3,290
28.123894
85
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/modules/losses.py
import tensorflow as tf import logging import tensorflow as tf import tensorflow_addons as tfa def masked_categorical_crossentropy(y_true, y_pred, y_mask, from_logits=False, ...
8,015
44.545455
126
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/modules/rnn.py
import tensorflow as tf def single_rnn_cell(units: int, cell_type: str = "gru", name: str = None): if cell_type == "gru": # Masking is not supported for CuDNN RNNs return tf.keras.layers.GRU( units, return_sequences=True, ...
2,070
29.014493
85
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/modules/weight_norm.py
import tensorflow as tf from tensorflow.python.keras.layers import convolutional class WeightNormDense(tf.keras.layers.Dense): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def build(self, input_shape): self.scale = self.add_weight( 'scale', sh...
2,022
30.123077
59
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/modules/trainer.py
import os from collections import defaultdict import random from pprint import PrettyPrinter import tensorflow as tf import numpy as np import language_evaluation from tqdm import tqdm import colorful from sklearn.metrics import accuracy_score from data import vocabulary as data_vocab from data.wizard_of_wikipedia im...
12,941
44.094077
114
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/models/base.py
from typing import Dict, Union import tensorflow as tf import colorlog import numpy as np from tensorflow.python.framework.ops import EagerTensor # pylint: disable=no-name-in-module from tensorflow.python.framework.ops import Tensor # pylint: disable=no-name-in-module from data.vocabulary import Vocabulary class ...
1,846
35.215686
127
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/models/sequential_knowledge_transformer.py
import os import tensorflow as tf #import tensorflow_addons as tfa import colorlog from utils.etc_utils import NEAR_INF from utils.config_utils import add_argument from utils.custom_argparsers import str2bool from data import vocabulary as data_vocab from data.holle import _MAX_NUM_MULTI from models import BaseModel ...
27,925
55.076305
146
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/models/transformer/embedding_layer.py
# Copyright 2018 The TensorFlow Authors. 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 applica...
3,863
35.8
80
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/models/transformer/ffn_layer.py
# Copyright 2018 The TensorFlow Authors. 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 applica...
3,051
33.681818
99
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/models/transformer/transformer.py
import tensorflow as tf import colorlog from models import BaseModel from models.transformer import model_utils from models.transformer import attention_layer from models.transformer.attention_layer import _float32_softmax from models.transformer import ffn_layer from models.transformer import beam_search from data im...
29,932
43.676119
119
py
sequential-knowledge-transformer
sequential-knowledge-transformer-master/models/transformer/attention_layer.py
# Copyright 2018 The TensorFlow Authors. 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 applica...
7,401
36.573604
104
py
DDRS-NAT
DDRS-NAT-master/setup.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import sys from setuptools import Extension, find_packages, setup if sys.version_info < (3, 6): sys.ex...
6,060
26.802752
92
py
DDRS-NAT
DDRS-NAT-master/generate.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Translate pre-processed data with a trained model. """ import ast import logging import math import os import sy...
13,923
35.260417
180
py
DDRS-NAT
DDRS-NAT-master/hubconf.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import functools import importlib from fairseq.hub_utils import ( # noqa; noqa BPEHubInterface as bpe, TokenizerHubInterface as toke...
2,001
27.6
82
py
DDRS-NAT
DDRS-NAT-master/train.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Train a new model on one or across multiple GPUs. """ import pdb import argparse import logging import math impor...
12,073
32.726257
93
py
DDRS-NAT
DDRS-NAT-master/examples/linformer/linformer_src/modules/multihead_linear_attention.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Dict, Optional, Tuple import torch import torch.nn.functional as F from fairseq import utils from fairseq.incr...
19,243
38.596708
98
py
DDRS-NAT
DDRS-NAT-master/examples/linformer/linformer_src/modules/linformer_sentence_encoder.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch.nn as nn from fairseq.modules import TransformerSentenceEncoder from .linformer_sentence_encoder_layer import Linfo...
6,319
36.176471
87
py
DDRS-NAT
DDRS-NAT-master/examples/wav2vec/vq-wav2vec_featurize.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Helper script to pre-compute embeddings for a wav2letter++ dataset """ import argparse import glob import os impor...
7,751
29.519685
87
py
DDRS-NAT
DDRS-NAT-master/examples/wav2vec/wav2vec_featurize.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Helper script to pre-compute embeddings for a wav2letter++ dataset """ import argparse import glob import os from ...
7,110
27.218254
135
py
DDRS-NAT
DDRS-NAT-master/examples/criss/save_encoder.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Translate pre-processed data with a trained model. """ import numpy as np import torch from fairseq import check...
7,420
33.67757
90
py
DDRS-NAT
DDRS-NAT-master/examples/translation_moe/translation_moe_src/mean_pool_gating_network.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn.functional as F class MeanPoolGatingNetwork(torch.nn.Module): """A simple mean-pooling gating network for s...
2,005
38.333333
84
py
DDRS-NAT
DDRS-NAT-master/examples/translation_moe/translation_moe_src/logsumexp_moe.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch class LogSumExpMoE(torch.autograd.Function): """Standard LogSumExp forward pass, but use *posterior* for the backward. ...
837
30.037037
78
py
DDRS-NAT
DDRS-NAT-master/examples/translation_moe/translation_moe_src/translation_moe.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from fairseq import metrics, utils from fairseq.tasks import register_task from fairseq.tasks.translation import TranslationTask ...
9,385
38.108333
95
py
DDRS-NAT
DDRS-NAT-master/examples/latent_depth/latent_depth_src/modules/latent_layers.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn class LayerSelect(nn.Module): """Compute samples (from a Gumbel-Sigmoid distribution) which is used a...
2,956
32.988506
86
py
DDRS-NAT
DDRS-NAT-master/examples/latent_depth/latent_depth_src/models/latent_transformer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Dict, Optional import torch.nn as nn from fairseq.models.fairseq_encoder import EncoderOut from fairseq.models.transf...
5,240
34.653061
88
py
DDRS-NAT
DDRS-NAT-master/examples/latent_depth/latent_depth_src/loss/latent_depth.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch from torch.nn.modules.loss import _Loss class LatentLayersKLLoss(_Loss): def __init__(self, args): sup...
3,802
37.03
86
py
DDRS-NAT
DDRS-NAT-master/examples/speech_to_text/prep_covost_data.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import csv import logging import os import os.path as op import shutil from tempfile import NamedTempor...
9,618
31.60678
88
py
DDRS-NAT
DDRS-NAT-master/examples/speech_to_text/prep_librispeech_data.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import logging import os import os.path as op import shutil from tempfile import NamedTemporaryFile im...
3,758
30.325
87
py
DDRS-NAT
DDRS-NAT-master/examples/speech_to_text/data_utils.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import csv import os import os.path as op import zipfile from functools import reduce from glob import glob from multip...
8,037
29.562738
88
py
DDRS-NAT
DDRS-NAT-master/examples/speech_to_text/prep_mustc_data.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import logging import os import os.path as op import shutil from itertools import groupby from tempfile...
7,506
36.348259
87
py
DDRS-NAT
DDRS-NAT-master/examples/roberta/commonsense_qa/commonsense_qa_task.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json import os import numpy as np import torch from fairseq.data import ( Dictionary, IdDataset, ListDataset, NestedDi...
6,124
31.068063
88
py
DDRS-NAT
DDRS-NAT-master/examples/roberta/wsc/wsc_task.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json import os import tempfile import numpy as np import torch import torch.nn.functional as F from fairseq import utils from fairseq....
13,524
32.644279
90
py
DDRS-NAT
DDRS-NAT-master/examples/roberta/wsc/wsc_criterion.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import utils from fairseq.criterions import LegacyFairseqCriterion, reg...
6,023
34.857143
87
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/infer.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Run inference for pre-processed data with a trained model. """ import logging import math import os import sys ...
15,443
32.212903
111
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/w2l_decoder.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Wav2letter decoders. """ import gc import itertools as it import os.path as osp import warnings from collections ...
14,874
33.116972
164
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/criterions/cross_entropy_acc.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import absolute_import, division, print_function, unicode_literals import logging import math import torch import torch.nn.f...
5,372
40.015267
85
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/criterions/ASG_loss.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from examples.speech_recognition.data.replabels import pack_replabels from fairseq import utils from fair...
5,857
33.25731
85
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/models/vggtransformer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import math from collections.abc import Iterable import torch import torch.nn as nn from examples.speech_recognition.data.dat...
37,226
35.497059
88
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/models/w2l_conv_glu_enc.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn as nn import torch.nn.functional as F from fairseq.models import ( Fairs...
6,078
33.151685
87
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/datasets/asr_prep_json.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import absolute_import, division, print_function, unicode_literals import argparse import concurrent.f...
3,775
28.968254
84
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/data/collaters.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ This module contains collection of classes which implement collate functionalities for various tasks. Collaters should know wh...
4,796
35.340909
84
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/data/data_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch def calc_mean_invstddev(feature): if len(feature.size()) != 2: raise ValueError("We expect the input feature to be ...
3,429
32.960396
84
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/data/asr_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import numpy as np from fairseq.data import FairseqDataset from . import data_utils from .collaters import Seq2SeqCollater class...
3,955
31.162602
82
py
DDRS-NAT
DDRS-NAT-master/examples/speech_recognition/tasks/speech_recognition.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json import os import re import sys import torch from examples.speech_recognition.data import AsrDataset from examples.speech_recognit...
5,397
33.164557
87
py
DDRS-NAT
DDRS-NAT-master/examples/byte_level_bpe/gru_transformer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the r...
5,027
45.555556
87
py
DDRS-NAT
DDRS-NAT-master/examples/simultaneous_translation/modules/monotonic_multihead_attention.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn as nn import torch.nn.functional as F from examples.simultaneous_translation.utils.functions import ...
21,794
33.983949
105
py
DDRS-NAT
DDRS-NAT-master/examples/simultaneous_translation/eval/eval_latency.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import json import torch from examples.simultaneous_translation.utils.latency import LatencyInference LATENCY_METRICS = [ ...
2,385
29.202532
88
py
DDRS-NAT
DDRS-NAT-master/examples/simultaneous_translation/models/transformer_monotonic_attention.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F from examples.simultaneous_translation.modules.monotonic_transformer_layer ...
10,868
32.650155
88
py
DDRS-NAT
DDRS-NAT-master/examples/simultaneous_translation/utils/functions.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch def exclusive_cumprod(tensor, dim: int, eps: float = 1e-10): """ Implementing exclusive cumprod. There is cumprod i...
3,950
25.34
87
py
DDRS-NAT
DDRS-NAT-master/examples/simultaneous_translation/utils/latency.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch class LatencyMetric(object): @staticmethod def length_from_padding_mask(padding_mask, batch_first: bool = False): ...
14,758
31.652655
88
py
DDRS-NAT
DDRS-NAT-master/examples/pointer_generator/pointer_generator_src/transformer_pg.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from typing import Any, Dict, Optional import torch import torch.nn as nn from fairseq import metrics, utils from fairseq.mode...
21,402
44.635394
102
py
DDRS-NAT
DDRS-NAT-master/examples/rxf/rxf_src/label_smoothed_cross_entropy_r3f.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import metrics, utils from fairseq.criterions import FairseqCriterion, ...
6,109
37.670886
91
py
DDRS-NAT
DDRS-NAT-master/examples/rxf/rxf_src/sentence_prediction_r3f.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import utils from fairseq.criterions import FairseqCriterion, register_...
6,515
37.105263
96
py
DDRS-NAT
DDRS-NAT-master/scripts/average_checkpoints.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import collections import os import re import torch from fairseq.file_io import PathManager def aver...
6,021
36.874214
175
py
DDRS-NAT
DDRS-NAT-master/tests/test_train.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import contextlib import logging import unittest from io import StringIO from unittest.mock import MagicMock, patch import torch from fairseq...
8,771
37.305677
101
py
DDRS-NAT
DDRS-NAT-master/tests/test_average_checkpoints.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import collections import os import shutil import tempfile import unittest import numpy as np import torch from scripts.average_checkpoints i...
4,385
31.488889
88
py
DDRS-NAT
DDRS-NAT-master/tests/test_reproducibility.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import contextlib import json import os import tempfile import unittest from io import StringIO import torch from . import test_binaries c...
4,528
31.582734
88
py
DDRS-NAT
DDRS-NAT-master/tests/test_sequence_scorer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import unittest import tests.utils as test_utils import torch from fairseq.sequence_scorer import SequenceScorer class Test...
4,150
33.305785
76
py
DDRS-NAT
DDRS-NAT-master/tests/test_memory_efficient_fp16.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import logging import unittest import torch from fairseq.optim.adam import FairseqAdam from fairseq.optim.fp16_optimizer impo...
2,000
28.865672
70
py
DDRS-NAT
DDRS-NAT-master/tests/test_lstm_jitable.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import tempfile import unittest import torch from fairseq.data.dictionary import Dictionary from fairseq.models.lstm import L...
4,041
33.844828
85
py
DDRS-NAT
DDRS-NAT-master/tests/test_multihead_attention.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from fairseq.modules.multihead_attention import MultiheadAttention class TestMultiheadAttention(unittest.TestC...
1,905
29.741935
80
py
DDRS-NAT
DDRS-NAT-master/tests/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import random import sys from io import StringIO import torch import torch.nn.functional as F from fairseq import o...
18,658
29.638752
86
py
DDRS-NAT
DDRS-NAT-master/tests/test_binaries.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import contextlib import logging import os import random import sys import tempfile import unittest from io import StringIO import torch from...
58,976
36.517176
105
py
DDRS-NAT
DDRS-NAT-master/tests/test_concat_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from fairseq.data import LanguagePairDataset, TokenBlockDataset from fairseq.data.concat_dataset import ConcatDa...
1,866
30.644068
81
py
DDRS-NAT
DDRS-NAT-master/tests/test_noising.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from typing import Dict, List import tests.utils as test_utils import torch from fairseq import utils from fairseq.data impor...
19,815
36.318267
87
py
DDRS-NAT
DDRS-NAT-master/tests/test_constraints.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys import unittest import torch from fairseq.token_generation_constraints import * def tensorize(constraints: List[List[int]]) -> t...
10,488
37.848148
147
py
DDRS-NAT
DDRS-NAT-master/tests/test_sparse_multihead_attention.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention class TestSparseMultiheadAtten...
3,738
31.513043
84
py
DDRS-NAT
DDRS-NAT-master/tests/test_export.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import tempfile import unittest import torch from fairseq.data.dictionary import Dictionary from fairs...
3,511
31.220183
86
py
DDRS-NAT
DDRS-NAT-master/tests/test_backtranslation_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import tests.utils as test_utils import torch from fairseq.data import ( BacktranslationDataset, LanguagePairDataset,...
4,140
32.395161
85
py
DDRS-NAT
DDRS-NAT-master/tests/test_fp16_optimizer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import copy import unittest import torch from fairseq.optim.fp16_optimizer import FP16Optimizer, MemoryEfficientFP16Optimizer...
3,124
30.565657
87
py
DDRS-NAT
DDRS-NAT-master/tests/test_sequence_generator.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import tempfile import unittest import tests.utils as test_utils import torch from fairseq import search from fairseq.data.di...
24,402
36.658951
88
py
DDRS-NAT
DDRS-NAT-master/tests/test_label_smoothing.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import copy import unittest import tests.utils as test_utils import torch from fairseq.criterions.cross_entropy import CrossE...
4,629
36.33871
88
py
DDRS-NAT
DDRS-NAT-master/tests/test_convtbc.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch import torch.nn as nn from fairseq.modules import ConvTBC class TestConvTBC(unittest.TestCase): def test_c...
1,745
30.745455
82
py
DDRS-NAT
DDRS-NAT-master/tests/test_token_block_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import tests.utils as test_utils import torch from fairseq.data import TokenBlockDataset class TestTokenBlockDataset(unitte...
3,011
36.65
87
py
DDRS-NAT
DDRS-NAT-master/tests/test_multi_corpus_sampled_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from collections import OrderedDict import numpy as np import torch from fairseq.data import LanguagePairDataset, TokenBlockD...
3,105
31.354167
79
py
DDRS-NAT
DDRS-NAT-master/tests/test_bmuf.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import random import unittest from multiprocessing import Manager import torch import torch.nn as nn from fairseq import dist...
5,350
29.930636
88
py
DDRS-NAT
DDRS-NAT-master/tests/test_dictionary.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import io import tempfile import unittest import torch from fairseq.data import Dictionary class TestDictionary(unittest.TestCase): def...
3,458
28.564103
80
py
DDRS-NAT
DDRS-NAT-master/tests/test_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from fairseq import utils class TestUtils(unittest.TestCase): def test_convert_padding_direction(self): ...
3,295
27.66087
78
py
DDRS-NAT
DDRS-NAT-master/tests/test_character_token_embedder.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from fairseq.data import Dictionary from fairseq.modules import CharacterTokenEmbedder class TestCharacterToke...
1,678
33.265306
81
py
DDRS-NAT
DDRS-NAT-master/tests/gpu/test_binaries_gpu.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import contextlib import logging import os import tempfile import unittest from io import StringIO import torch from fairseq import options f...
9,928
31.447712
92
py
DDRS-NAT
DDRS-NAT-master/tests/speech_recognition/test_data_utils.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from examples.speech_recognition.data import data_utils class DataUtilsTest(unittest.Tes...
1,736
26.571429
65
py
DDRS-NAT
DDRS-NAT-master/tests/speech_recognition/asr_test_base.py
#!/usr/bin/env python3 import argparse import os import unittest from inspect import currentframe, getframeinfo import numpy as np import torch from examples.speech_recognition.data.data_utils import lengths_to_encoder_padding_mask from fairseq.data import data_utils as fairseq_data_utils from fairseq.data.dictionary...
19,495
33.876565
87
py
DDRS-NAT
DDRS-NAT-master/tests/speech_recognition/test_collaters.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import numpy as np import torch from examples.speech_recognition.data.collaters import Seq2SeqCollater...
2,048
33.728814
87
py
DDRS-NAT
DDRS-NAT-master/fairseq/checkpoint_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import collections import logging import os import re import traceback from collections import OrderedDict from typing import Union import to...
21,300
36.109756
114
py
DDRS-NAT
DDRS-NAT-master/fairseq/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb import argparse import contextlib import copy import importlib import logging import os import sys import tempfile import warnings f...
22,615
31.216524
111
py