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 |
|---|---|---|---|---|---|---|
bluebert | bluebert-master/mt-bluebert/mt_bluebert/data_utils/utils.py | # Copyright (c) Microsoft. All rights reserved.
import random
import torch
import numpy
import subprocess
class AverageMeter(object):
"""Computes and stores the average and current value."""
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.su... | 1,244 | 24.408163 | 66 | py |
bluebert | bluebert-master/mt-bluebert/scripts/convert_tf_to_pt.py | # This scripts is to convert Google's TF BERT to the pytorch version which is used by mt-dnn.
# It is a supplementary script.
# Note that it relies on tensorflow==1.12.0 which does not support by our released docker.
# If you want to use this, please install tensorflow==1.12.0 by: pip install tensorflow==1.12.0
# Some... | 8,570 | 42.729592 | 95 | py |
bluebert | bluebert-master/mribert/sequence_classification.py | """
Usage:
my_program.py [options]
Options:
--do_train Whether to run training.
--do_test Whether to run testing.
--do_predict Whether to run predicting.
--do_debug
--log_file=<file> path for log file. [default: log.txt]
--csv_logger=<file> ... | 13,154 | 37.464912 | 126 | py |
bluebert | bluebert-master/elmo/elmoft.py | #!/usr/bin/env python
# -*- coding=utf-8 -*-
###########################################################################
# File Name: elmo_finetuning.py
# Author: Shankai Yan
# E-mail: shankai.yan@nih.gov
# Created Time: 2019-03-29 19:27:12
###########################################################################
#
... | 65,502 | 71.219405 | 959 | py |
RotationCorrection | RotationCorrection-main/Codes/tf_spatial_transform_local.py | import tensorflow as tf
import numpy as np
import math
import tensorDLT_local
from keras.layers import UpSampling2D
import constant
grid_w = constant.GRID_W
grid_h = constant.GRID_H
def transformer(U, theta, name='SpatialTransformer', **kwargs):
"""Spatial Transformer Layer
Implements a spatial transformer l... | 10,939 | 39.07326 | 154 | py |
RotationCorrection | RotationCorrection-main/Codes/tf_mesh2flow.py | import tensorflow as tf
import numpy as np
import math
import tensorDLT_local
from keras.layers import UpSampling2D
import constant
grid_w = constant.GRID_W
grid_h = constant.GRID_H
def mesh2flow(mesh, name='Mesh2Flow', **kwargs):
"""Spatial Transformer Layer
Implements a spatial transformer layer as describ... | 9,924 | 37.02682 | 154 | py |
graph_attention_pool | graph_attention_pool-master/main.py | import argparse
import random
import datetime
from torchvision import transforms
from graphdata import *
from train_test import *
import warnings
warnings.filterwarnings("once")
def parse_args():
parser = argparse.ArgumentParser(description='Run experiments with Graph Neural Networks')
# Dataset
parser.ad... | 23,756 | 59.144304 | 238 | py |
graph_attention_pool | graph_attention_pool-master/extract_superpixels.py | # Compute superpixels for MNIST/CIFAR-10 using SLIC algorithm
# https://scikit-image.org/docs/dev/api/skimage.segmentation.html#skimage.segmentation.slic
import numpy as np
import random
import os
import scipy
import pickle
from skimage.segmentation import slic
from torchvision import datasets
import multiprocessing a... | 6,355 | 44.078014 | 177 | py |
graph_attention_pool | graph_attention_pool-master/chebygin.py | import numpy as np
import torch
import torch.sparse
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
from attention_pooling import *
from utils import *
class ChebyGINLayer(nn.Module):
'''
General Graph Neural Network layer that depending on arguments can be:
... | 10,695 | 40.945098 | 149 | py |
graph_attention_pool | graph_attention_pool-master/graphdata.py | import numpy as np
import os
from os.path import join as pjoin
import pickle
import copy
import torch
import torch.utils
import torch.utils.data
import torch.nn.functional as F
import torchvision
from scipy.spatial.distance import cdist
from utils import *
def compute_adjacency_matrix_images(coord, sigma=0.1):
co... | 29,128 | 42.154074 | 147 | py |
graph_attention_pool | graph_attention_pool-master/utils.py | import numpy as np
import os
import torch
import copy
from graphdata import *
import torch.nn.functional as F
from torchvision import datasets, transforms
from sklearn.metrics import roc_auc_score
import numbers
import random
def load_save_noise(f, noise_shape):
if os.path.isfile(f):
print('loading noise ... | 8,522 | 33.930328 | 134 | py |
graph_attention_pool | graph_attention_pool-master/attention_pooling.py | import numpy as np
import torch
import torch.sparse
import torch.nn as nn
import torch.nn.functional as F
from utils import *
class AttentionPooling(nn.Module):
'''
Graph pooling layer implementing top-k and threshold-based pooling.
'''
def __init__(self,
in_features, # feature dimen... | 12,420 | 48.486056 | 165 | py |
graph_attention_pool | graph_attention_pool-master/train_test.py | import time
import torch
from torch.utils.data import DataLoader
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from chebygin import *
from utils import *
from graphdata import *
import torch.multiprocessing as mp
import multiprocessing
try:
import ax
from ax.service.managed_loop im... | 21,879 | 47.087912 | 179 | py |
option-critic-pytorch | option-critic-pytorch-master/main.py | import numpy as np
import argparse
import torch
from copy import deepcopy
from option_critic import OptionCriticFeatures, OptionCriticConv
from option_critic import critic_loss as critic_loss_fn
from option_critic import actor_loss as actor_loss_fn
from experience_replay import ReplayBuffer
from utils import make_env... | 7,063 | 47.383562 | 126 | py |
option-critic-pytorch | option-critic-pytorch-master/option_critic.py | import torch
import torch.nn as nn
from torch.distributions import Categorical, Bernoulli
from math import exp
import numpy as np
from utils import to_tensor
class OptionCriticConv(nn.Module):
def __init__(self,
in_features,
num_actions,
num_options,
... | 8,652 | 34.463115 | 129 | py |
option-critic-pytorch | option-critic-pytorch-master/utils.py | import gym
import numpy as np
import torch
from gym.wrappers import AtariPreprocessing, TransformReward
from gym.wrappers import FrameStack as FrameStack_
from fourrooms import Fourrooms
class LazyFrames(object):
def __init__(self, frames):
self._frames = frames
def __array__(self, dtype=None):
... | 1,371 | 24.886792 | 106 | py |
option-critic-pytorch | option-critic-pytorch-master/logger.py | import logging
import os
import time
import numpy as np
from torch.utils.tensorboard import SummaryWriter
class Logger():
def __init__(self, logdir, run_name):
self.log_name = logdir + '/' + run_name
self.tf_writer = None
self.start_time = time.time()
self.n_eps = 0
if not ... | 2,511 | 46.396226 | 143 | py |
fastracer-pmam-2022 | fastracer-pmam-2022-main/fastracer/tdebug-llvm/clang/docs/conf.py | # -*- coding: utf-8 -*-
#
# Clang documentation build configuration file, created by
# sphinx-quickstart on Sun Dec 9 20:01:55 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All c... | 9,088 | 32.29304 | 83 | py |
fastracer-pmam-2022 | fastracer-pmam-2022-main/fastracer/tdebug-llvm/clang/docs/analyzer/conf.py | # -*- coding: utf-8 -*-
#
# Clang Static Analyzer documentation build configuration file, created by
# sphinx-quickstart on Wed Jan 2 15:54:28 2013.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated... | 8,026 | 31.497976 | 80 | py |
awpy | awpy-main/docs/conf.py | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... | 5,562 | 28.748663 | 81 | py |
parsing-as-pretraining | parsing-as-pretraining-master/run_token_classifier.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace 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... | 44,196 | 42.629812 | 139 | py |
parsing-as-pretraining | parsing-as-pretraining-master/tree2labels/baselines.py | '''
It evaluates some traditional baselines using for regular PoS-tagging or chunking
It uses the implementations from the NLTK
TRAINING
PYTHONPATH=. python baselines/baselines.py \
--train /home/david.vilares/Escritorio/Papers/seq2constree/dataset/gold-tags-ptb-train.seqtrees \
--test /home/david.vilares/Escritori... | 23,149 | 48.360341 | 138 | py |
parsing-as-pretraining | parsing-as-pretraining-master/tree2labels/baseline_utils.py | from keras.utils import np_utils
from keras.models import Sequential, Model
from keras.layers import Dense, Dropout, Activation, Embedding, Input, Flatten
from keras.wrappers.scikit_learn import KerasClassifier
# Fit LabelEncoder with our list of classes
from sklearn.preprocessing import LabelEncoder
import keras
impo... | 17,773 | 35.052738 | 140 | py |
parsing-as-pretraining | parsing-as-pretraining-master/NCRFpp/main.py | # -*- coding: utf-8 -*-
# @Author: Jie
# @Date: 2017-06-15 14:11:08
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2019-01-14 16:09:16
from __future__ import print_function
import time
import sys
import argparse
import random
import torch
import gc
import torch.nn as nn
import... | 27,670 | 43.558776 | 253 | py |
parsing-as-pretraining | parsing-as-pretraining-master/NCRFpp/model/wordsequence.py | # -*- coding: utf-8 -*-
# @Author: Jie Yang
# @Date: 2017-10-17 16:47:32
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2019-01-11 13:55:41
from __future__ import print_function
from __future__ import absolute_import
import torch
import torch.nn as nn
import torch.nn.functional... | 17,182 | 47.677054 | 159 | py |
parsing-as-pretraining | parsing-as-pretraining-master/NCRFpp/model/wordrep.py | # -*- coding: utf-8 -*-
# @Author: Jie Yang
# @Date: 2017-10-17 16:47:32
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2019-01-10 16:41:16
from __future__ import print_function
from __future__ import absolute_import
import torch
import torch.nn as nn
import numpy as np
from .c... | 9,348 | 49.809783 | 183 | py |
parsing-as-pretraining | parsing-as-pretraining-master/NCRFpp/model/sentclassifier.py | # -*- coding: utf-8 -*-
# @Author: Jie Yang
# @Date: 2019-01-01 21:11:50
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2019-01-14 14:56:28
from __future__ import print_function
from __future__ import absolute_import
import torch
import torch.nn as nn
import torch.nn.functiona... | 2,329 | 39.877193 | 153 | py |
parsing-as-pretraining | parsing-as-pretraining-master/NCRFpp/model/charbigru.py | # -*- coding: utf-8 -*-
# @Author: Jie Yang
# @Date: 2017-10-17 16:47:32
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2018-10-18 11:12:13
from __future__ import print_function
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_s... | 3,452 | 43.269231 | 126 | py |
parsing-as-pretraining | parsing-as-pretraining-master/NCRFpp/model/charcnn.py | # -*- coding: utf-8 -*-
# @Author: Jie Yang
# @Date: 2017-10-17 16:47:32
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2019-01-18 21:06:06
from __future__ import print_function
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class CharCNN... | 3,086 | 40.716216 | 121 | py |
parsing-as-pretraining | parsing-as-pretraining-master/NCRFpp/model/charbilstm.py | # -*- coding: utf-8 -*-
# @Author: Jie Yang
# @Date: 2017-10-17 16:47:32
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2018-10-18 11:19:37
from __future__ import print_function
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_s... | 3,561 | 43.525 | 126 | py |
parsing-as-pretraining | parsing-as-pretraining-master/NCRFpp/model/crf.py | # -*- coding: utf-8 -*-
# @Author: Jie Yang
# @Date: 2017-12-04 23:19:38
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2018-12-16 22:15:56
from __future__ import print_function
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F... | 21,777 | 48.6082 | 233 | py |
parsing-as-pretraining | parsing-as-pretraining-master/NCRFpp/model/seqlabel.py | # -*- coding: utf-8 -*-
# @Author: Jie Yang
# @Date: 2017-10-17 16:47:32
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2019-01-01 21:10:00
from __future__ import print_function
from __future__ import absolute_import
import torch
import torch.nn as nn
import torch.nn.functiona... | 3,970 | 42.163043 | 152 | py |
biokge | biokge-main/src/trainer.py | import torch
import tqdm
from torch.nn import functional as F
from torch.utils.data import DataLoader
import wandb
from .evaluators.classification_evaluator import calculate_metrics
from .models.classifier import Classifier
class Trainer:
def __init__(
self,
configs,
entity_size,
... | 5,954 | 33.622093 | 88 | py |
biokge | biokge-main/src/models/classifier.py | import torch
class Classifier(torch.nn.Module):
def __init__(self, entity_size: int, num_relations: int, rank: int):
super().__init__()
self.entity_size = entity_size
self.num_relations = num_relations
self.rank = rank
self.entity_embeddings = torch.nn.Embedding(entity_si... | 1,329 | 34 | 76 | py |
biokge | biokge-main/src/models/regularizers.py | from abc import ABC, abstractmethod
from typing import Tuple
import torch
from torch import nn
class Regularizer(ABC):
def __init__(self, lmbda: float):
"""
Base class of regularizers
Args:
lmbda (float): Penalty coefficient of a regularizer
"""
self.lmbda = l... | 1,921 | 24.289474 | 69 | py |
biokge | biokge-main/src/utils/logger.py | from typing import List
import torch
class Logger(object):
def __init__(self, output_dir: str, filename: str) -> None:
"""
A logger object to mainly store results to a txt file
Args:
output_dir (str): Output directory of the experiment
filename (str): Name of the ... | 1,268 | 29.214286 | 72 | py |
biokge | biokge-main/src/utils/common_utils.py | import os
import random
from datetime import datetime
from typing import Optional, Tuple
import numpy as np
import torch
import yaml
from torch import nn
def setup_experiment_folder(outputs_dir: str) -> Tuple[str, str]:
"""
Utility function to create and setup the experiment output directory.
Return both... | 3,144 | 27.590909 | 93 | py |
biokge | biokge-main/scripts/benchmarking/triple_classification.py | import argparse
import random
import numpy
import sklearn
import torch
import kge
import kge.model
def evaluate(model_path):
# Load model
model = kge.model.KgeModel.create_from(kge.util.io.load_checkpoint(model_path))
# Load data
dataset = model.dataset
train_triples = dataset.load_triples("tr... | 6,796 | 31.061321 | 121 | py |
BIFI | BIFI-main/utils/fairseq/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
from setuptools import setup, find_packages, Extension
import sys
if sys.version_info < (3, 6):
sys.exi... | 4,365 | 25.785276 | 101 | py |
BIFI | BIFI-main/utils/fairseq/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
from fairseq.hub_utils import BPEHubInterface as bpe # noqa
from fairseq.hub_utils import TokenizerHubInterface as tokenize... | 1,432 | 28.244898 | 78 | py |
BIFI | BIFI-main/utils/fairseq/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 pprint
import glob, os, argparse
im... | 7,706 | 29.705179 | 111 | py |
BIFI | BIFI-main/utils/fairseq/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,102 | 28.970464 | 135 | py |
BIFI | BIFI-main/utils/fairseq/examples/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,007 | 38.372549 | 84 | py |
BIFI | BIFI-main/utils/fairseq/examples/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.
... | 835 | 29.962963 | 78 | py |
BIFI | BIFI-main/utils/fairseq/examples/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,078 | 40.268182 | 96 | py |
BIFI | BIFI-main/utils/fairseq/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 (
data_utils,
Dictionary,
encoders,
IdDataset... | 5,921 | 32.84 | 103 | py |
BIFI | BIFI-main/utils/fairseq/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,148 | 33.970745 | 103 | py |
BIFI | BIFI-main/utils/fairseq/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.data import encoders
from fairseq.criterions... | 6,034 | 35.137725 | 88 | py |
BIFI | BIFI-main/utils/fairseq/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 sen... | 9,010 | 31.886861 | 88 | py |
BIFI | BIFI-main/utils/fairseq/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 math
import itertools as it
import torch
from fairseq import utils
from examples.s... | 5,896 | 34.10119 | 85 | py |
BIFI | BIFI-main/utils/fairseq/examples/speech_recognition/criterions/CTC_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 logging
import math
from itertools import groupby
import torch
import torch.nn.functional as F
from fairseq im... | 7,008 | 34.94359 | 87 | py |
BIFI | BIFI-main/utils/fairseq/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 |
BIFI | BIFI-main/utils/fairseq/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 math
import numpy as np
import torch
from fairseq import utils
from fairseq.criterions import LegacyFairseqCri... | 5,509 | 34.548387 | 85 | py |
BIFI | BIFI-main/utils/fairseq/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 fairseq import utils
from fairseq.mo... | 37,045 | 35.788481 | 88 | py |
BIFI | BIFI-main/utils/fairseq/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... | 5,987 | 33.217143 | 87 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
from fairseq.data import Dictionary
from fairseq.tasks import FairseqTask, register_task
from ex... | 4,531 | 32.57037 | 87 | py |
BIFI | BIFI-main/utils/fairseq/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,088 | 47.466667 | 87 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
import os
import re
def average_checkpoints(inputs):
"""Loads che... | 5,676 | 38.423611 | 175 | py |
BIFI | BIFI-main/utils/fairseq/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
from io import StringIO
import unittest
from unittest.mock import MagicMock, patch
import torch
from fairseq import data, ... | 4,690 | 35.364341 | 94 | py |
BIFI | BIFI-main/utils/fairseq/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 tempfile
import unittest
import shutil
import numpy as np
import torch
from torch import nn
from script... | 4,494 | 30.215278 | 80 | py |
BIFI | BIFI-main/utils/fairseq/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
from io import StringIO
import json
import os
import tempfile
import unittest
import torch
from . import test_binaries
c... | 3,459 | 34.670103 | 100 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
from fairseq.sequence_scorer import SequenceScorer
import tests.utils as test_utils
class Te... | 3,949 | 33.051724 | 75 | py |
BIFI | BIFI-main/utils/fairseq/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 imp... | 2,002 | 28.028986 | 70 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
import unittest
from fairseq.modules.multihead_attention import MultiheadAttention
class TestMultiheadAttention(unittest.TestCa... | 1,904 | 30.229508 | 80 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.data import Dictionary
from fairseq.data.... | 9,154 | 30.898955 | 101 | py |
BIFI | BIFI-main/utils/fairseq/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
from io import StringIO
import logging
import os
import random
import sys
import tempfile
import unittest
import torch
fro... | 45,457 | 40.363057 | 122 | py |
BIFI | BIFI-main/utils/fairseq/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,943 | 28.907692 | 66 | py |
BIFI | BIFI-main/utils/fairseq/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,779 | 36.533207 | 87 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
import unittest
from fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention
class TestSparseMultiheadAttent... | 2,545 | 50.959184 | 114 | py |
BIFI | BIFI-main/utils/fairseq/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,535 | 31.740741 | 86 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
from fairseq.data import (
BacktranslationDataset,
LanguagePairDataset,
TransformEosDataset,
)
from... | 4,004 | 33.525862 | 90 | py |
BIFI | BIFI-main/utils/fairseq/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 unittest
import torch
from fairseq import search
from fairseq.sequence_generator import SequenceGenerator
import tes... | 17,439 | 40.035294 | 102 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
from fairseq.criterions.cross_entropy import CrossEntropyCriterion
from fairseq.cri... | 4,235 | 41.36 | 101 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
import unittest
from fairseq.modules import ConvTBC
import torch.nn as nn
class TestConvTBC(unittest.TestCase):
def test_c... | 1,679 | 33.285714 | 102 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
from fairseq.data import TokenBlockDataset
import tests.utils as test_utils
class TestTokenBlockDataset(unit... | 2,970 | 36.607595 | 89 | py |
BIFI | BIFI-main/utils/fairseq/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 |
BIFI | BIFI-main/utils/fairseq/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
from multiprocessing import Manager
import random
import unittest
import torch
import torch.nn as nn
from fairseq import dis... | 4,636 | 28.535032 | 88 | py |
BIFI | BIFI-main/utils/fairseq/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):
d... | 3,336 | 27.521368 | 80 | py |
BIFI | BIFI-main/utils/fairseq/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):
... | 2,878 | 27.50495 | 73 | py |
BIFI | BIFI-main/utils/fairseq/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 torch
import unittest
from fairseq.data import Dictionary
from fairseq.modules import CharacterTokenEmbedder
class TestCharacterToke... | 1,656 | 34.255319 | 96 | py |
BIFI | BIFI-main/utils/fairseq/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 fairseq.data import data_utils as fairseq_data_utils
from fairseq.data.dictionary import Dictionary
from fairseq.models import (
BaseFairseqModel,
FairseqDecoder... | 19,491 | 33.9319 | 92 | py |
BIFI | BIFI-main/utils/fairseq/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 |
BIFI | BIFI-main/utils/fairseq/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... | 18,554 | 36.035928 | 114 | py |
BIFI | BIFI-main/utils/fairseq/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 contextlib
import copy
import importlib.util
import logging
import math
import os
import sys
import warnings
from collections import de... | 15,998 | 31.062124 | 111 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/hub_utils.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.
import argparse
import copy
import logging
import os
from typing import List, Dict, Iterator, Tuple, Any
import tor... | 10,125 | 36.227941 | 107 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/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 torch
import sys
from fairseq import utils
class SequenceScorer(object):
"""Scores the target for a given source sentence."""
... | 4,835 | 36.78125 | 107 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/binarizer.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
from collections import Counter
from fairseq.tokenizer import tokenize_line
import torch
def safe_readline(f):
pos = f.tell()... | 3,231 | 29.780952 | 84 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/distributed_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 logging
import os
import pickle
import socket
import struct
import subprocess
import warnings
from collections import OrderedDict
from ... | 9,197 | 35.070588 | 107 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/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 math
import torch
from fairseq import search, utils
from fairseq.data import data_utils
from fairseq.models import FairseqIncremental... | 30,021 | 41.403955 | 118 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/legacy_distributed_data_parallel.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.
"""
A modified version of the legacy DistributedDataParallel module that uses c10d
communication primitives. This version is simpler than the ... | 6,724 | 36.154696 | 88 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/options.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 sys
from typing import Callable, List, Optional
import torch
from fairseq import utils
from fairseq.data.indexed_data... | 32,607 | 51.849271 | 120 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/bleu.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 ctypes
import math
import torch
try:
from fairseq import libbleu
except ImportError as e:
import sys
sys.stderr.write('ERR... | 3,955 | 29.430769 | 83 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/file_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.
"""
Utilities for working with the local dataset cache.
This file is adapted from `AllenNLP <https://github.com/allenai/allennlp>`_.
and `hugg... | 11,036 | 32.243976 | 103 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/incremental_decoding_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.
from typing import Dict, Optional
import uuid
from torch import Tensor
class FairseqIncrementalState(object):
def __init__(self, *args... | 1,760 | 33.529412 | 112 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/search.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 Optional, List
import torch
import torch.nn as nn
from torch import Tensor
class Search(nn.Module):
def ... | 12,739 | 36.251462 | 100 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/nan_detector.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
import torch
logger = logging.getLogger(__name__)
class NanDetector:
"""
Detects the first NaN or Inf in forward... | 2,982 | 32.144444 | 119 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/iterative_refinement_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.
from collections import namedtuple
import torch
import numpy as np
from fairseq import utils
DecoderOut = namedtuple('IterativeRefinementD... | 12,332 | 38.028481 | 120 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/trainer.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.
"""
Train a network across multiple GPUs.
"""
import contextlib
from itertools import chain
import logging
import sys
from typing import Any,... | 29,348 | 36.626923 | 101 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/transformer_sentence_encoder_layer.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 fairseq import utils
from fairseq.modules import (
LayerNorm,
... | 2,830 | 30.10989 | 80 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/learned_positional_embedding.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.nn as nn
from fairseq import utils
class LearnedPositionalEmbedding(nn.Embedding):
"""
This module learns positional e... | 1,826 | 37.0625 | 94 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.