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
FIT
FIT-main/src/structure/nbp_transe.py
import torch from torch import nn from .neural_binary_predicate import NeuralBinaryPredicate class TransE(nn.Module, NeuralBinaryPredicate): def __init__(self, num_entities, num_relations, embedding_dim, p, margin, scale, device, **kwargs): super(TransE, self).__init__() self.num_entities = num_e...
2,716
39.552239
103
py
FIT
FIT-main/src/structure/nbp_swtranse.py
import torch from torch import nn from .neural_binary_predicate import NeuralBinaryPredicate class SWTransE(nn.Module, NeuralBinaryPredicate): def __init__(self, num_entities, num_relations, embedding_dim, num_particles, p, margin, scale, device, **kwargs): super(SWTransE, self).__init__() self....
3,482
36.858696
118
py
FIT
FIT-main/src/structure/.ipynb_checkpoints/nbp_complex-checkpoint.py
import torch from torch import nn from .neural_binary_predicate import NeuralBinaryPredicate class ComplEx(NeuralBinaryPredicate, nn.Module): def __init__(self, num_entities: int, num_relations: int, embedding_dim: int, scale: float = 1, ...
5,701
40.318841
114
py
FIT
FIT-main/src/structure/.ipynb_checkpoints/neural_binary_predicate-checkpoint.py
from abc import abstractmethod import torch class NeuralBinaryPredicate: num_entities: int num_relations: int device: torch.device scale: float @abstractmethod def embedding_score(self, head_emb, rel_emb, tail_emb): """ This method computes the score for the triple given the ...
3,953
34.303571
114
py
FIT
FIT-main/src/utils/recorder.py
import json import os from typing import Dict from torch.utils.tensorboard import SummaryWriter class JSONlRecorder: def __init__(self, jsonl_filename): self.jsonl_filename = jsonl_filename def append_record(self, data: Dict): line_content = json.dumps(data) with open(self.jsonl_file...
1,351
27.765957
85
py
FIT
FIT-main/src/utils/aggregate_query.py
import argparse import json import os.path as osp import torch parser = argparse.ArgumentParser() parser.add_argument("--mode", type=str, default='test', choices=['valid', 'test']) parser.add_argument("--data_folder", type=str, default='data/FB15k-237-EFO1') parser.add_argument("--max", type=int, default=1000) if __...
1,076
34.9
94
py
FIT
FIT-main/src/utils/data.py
import json from random import shuffle import torch from torch.utils.data import DataLoader from src.language.fof import ConjunctiveFormula, DisjunctiveFormula, Disjunction from src.language.grammar import parse_lstr_to_lformula, parse_lstr_to_lformula_v2, concate_iu_chains, \ parse_lstr_to_disjunctive_formula ...
9,973
32.582492
104
py
FIT
FIT-main/src/utils/data_util.py
from itertools import chain from typing import Union, List import torch from torch.nn.utils.rnn import pad_sequence def _iter_triple_from_tsv(triple_file, to_int, check_size): with open(triple_file, 'rt') as f: for line in f.readlines(): triple = line.strip().split() if check_size...
2,836
35.371795
78
py
FIT
FIT-main/src/utils/config.py
import argparse import json import os from abc import abstractmethod import torch import yaml from datetime import datetime class Config: default_kv = {} def __init__(self, config_dict) -> None: self.params = {} for k in self.default_kv: v = config_dict.pop(k, self.default_kv[k...
7,684
30.756198
86
py
FIT
FIT-main/src/utils/class_util.py
import collections import hashlib from functools import partial from itertools import repeat import re import warnings import torch import torch.nn as nn import torch.nn.functional as F import os from os.path import join, dirname, realpath, exists from shutil import rmtree import time import pickle import json import n...
4,454
31.757353
106
py
FIT
FIT-main/src/learner/sampler.py
import torch def lcwa_negative_sampling(phead_id_ten, ptail_id_ten, num_entities, num_neg_samples): device = phead_id_ten.device original_shape = phead_id_ten.shape neg_sample_shape = original_shape + (num_neg_samples,) ...
1,206
30.763158
71
py
FIT
FIT-main/src/learner/elementary.py
from typing import List import random import torch from .abstract_learner import Learner from ..utils.data_util import tensorize_batch_entities from ..structure import KnowledgeGraph, NeuralBinaryPredicate class BatchedEFG: def __init__(self, finite_model: KnowledgeGraph, neural...
8,596
35.739316
88
py
FIT
FIT-main/src/learner/isomorphic.py
from torch.utils.data import DataLoader from .abstract_learner import Learner, LearnerForwardOutput from .sampler import lcwa_negative_sampling, rel_negative_sampling from ..structure import KnowledgeGraph, NeuralBinaryPredicate class IsomorphicLearner(Learner): def __init__(self, kg: KnowledgeG...
1,737
31.792453
81
py
FIT
FIT-main/src/language/fof.py
""" A base class for existential first order formulas It supports the verification and query answering tasks given the formula For the verification, there is no free_vars For the query answering, there should be at least one free_vars Several assumptions about the formula - In DNF - Only with existential quantifier The...
31,017
37.531677
120
py
FIT
FIT-main/src/language/tnorm.py
from abc import abstractmethod import torch class Tnorm: @classmethod def negation(self, a): return 1-a class ProductTNorm(Tnorm): @classmethod def conjunction(self, a, b): return a * b @classmethod def disjunction(self, a, b): return a + b - a * b class GodelTNorm(...
491
16.571429
32
py
FIT
FIT-main/test/test_data_class.py
import argparse import json import logging import os import os.path as osp import random from collections import defaultdict import numpy as np import torch import torch.nn.functional as F import tqdm from torch import nn from src.language.tnorm import GodelTNorm, ProductTNorm, Tnorm from src.structure import get_nbp...
5,249
37.321168
222
py
FIT
FIT-main/data_preparation/filter_matrix.py
import argparse import json import logging import os import os.path as osp import random from collections import defaultdict from typing import List import torch import pickle from src.structure.knowledge_graph import KnowledgeGraph from src.structure.knowledge_graph_index import KGIndex parser = argparse.ArgumentPa...
2,792
43.333333
116
py
FIT
FIT-main/data_preparation/sample_query.py
import argparse import json import logging import os import os.path as osp import random from collections import defaultdict import numpy as np import torch import torch.nn.functional as F import tqdm from torch import nn from src.language.tnorm import GodelTNorm, ProductTNorm, Tnorm from src.structure import get_nbp...
9,607
45.868293
119
py
rxngenerator
rxngenerator-master/main.py
import rdkit import rdkit.Chem as Chem from rdkit.Chem import QED from collections import deque import torch import torch.nn as nn import torch.optim as optim import torch.optim.lr_scheduler as lr_scheduler from nnutils import create_var import math import torch.nn.functional as F from torch.utils.data import DataLoad...
13,438
31.305288
184
py
rxngenerator
rxngenerator-master/sample.py
import sys sys.path.append('./rxnft_vae') import torch import torch.nn as nn import torch.optim as optim import torch.optim.lr_scheduler as lr_scheduler from torch.utils.data import DataLoader from torch.autograd import Variable import math, random, sys from optparse import OptionParser from collections import deque ...
3,441
32.096154
163
py
rxngenerator
rxngenerator-master/trainvae.py
import sys sys.path.append('./rxnft_vae') import torch import torch.nn as nn import torch.optim as optim import torch.optim.lr_scheduler as lr_scheduler from torch.utils.data import DataLoader from torch.autograd import Variable import math, random, sys from optparse import OptionParser from collections import deque ...
7,932
35.389908
184
py
rxngenerator
rxngenerator-master/Theano-master/theano/tensor/nnet/abstract_conv.py
""" Abstract conv interface """ from __future__ import absolute_import, print_function, division import logging from six import reraise, integer_types import sys import theano from theano.tensor import as_tensor_variable, patternbroadcast from theano.tensor import get_scalar_constant_value, NotScalarConstantError fr...
46,519
40.98556
95
py
rxngenerator
rxngenerator-master/Theano-master/theano/tensor/nnet/__init__.py
from __future__ import absolute_import, print_function, division from .nnet import ( CrossentropyCategorical1Hot, CrossentropyCategorical1HotGrad, CrossentropySoftmax1HotWithBiasDx, CrossentropySoftmaxArgmax1HotWithBias, LogSoftmax, Prepend_scalar_constant_to_each_row, Prepend_scalar_to_each_row, Softma...
6,330
42.965278
81
py
rxngenerator
rxngenerator-master/bo/run_bo.py
import sys sys.path.append('../rxnft_vae') import rdkit import rdkit.Chem as Chem from rdkit.Chem import QED, Descriptors, rdmolops import torch import torch.nn as nn import torch.optim as optim import torch.optim.lr_scheduler as lr_scheduler from torch.utils.data import DataLoader from torch.autograd import Variable ...
10,018
31.423948
163
py
rxngenerator
rxngenerator-master/rxnft_vae/ftdecoder.py
import torch import torch.nn as nn from nnutils import create_var, GRU from fragment import FragmentVocab, FragmentTree, FragmentNode from chemutils import set_atommap, enum_assemble, enum_attach import copy MAX_NB = 16 MAX_DECODING_LEN = 100 class FTDecoder(nn.Module): def __init__(self, ftvocab, hidden_size, late...
10,999
31.448378
106
py
rxngenerator
rxngenerator-master/rxnft_vae/evaluate.py
import rdkit import rdkit.Chem as Chem from rdkit.Chem import QED from collections import deque import torch import torch.nn as nn import torch.optim as optim import torch.optim.lr_scheduler as lr_scheduler from nnutils import create_var import math import torch.nn.functional as F from torch.utils.data import DataLoad...
6,342
29.495192
138
py
rxngenerator
rxngenerator-master/rxnft_vae/rxndecoder.py
import rdkit import rdkit.Chem as Chem from rdkit.Chem import Descriptors from rdkit.Chem import MolFromSmiles, MolToSmiles from rdkit.Chem import rdmolops import torch import torch.nn as nn from nnutils import create_var, attention import math import torch.nn.functional as F from rdkit.Chem import rdChemReactions from...
34,079
33.918033
170
py
rxngenerator
rxngenerator-master/rxnft_vae/nnutils.py
import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F def create_var(tensor, requires_grad = None): if requires_grad is None: return Variable(tensor)#.cuda() else: return Variable(tensor, requires_grad=requires_grad)#.cuda() def index_select_ND(source, dim, index)...
1,636
32.408163
66
py
rxngenerator
rxngenerator-master/rxnft_vae/mpn.py
import torch import torch.nn as nn import rdkit.Chem as Chem import torch.nn.functional as F from reaction_utils import get_mol_from_smiles from nnutils import * ELEM_LIST = ['C', 'N', 'O', 'S' 'F', 'Si', 'P', 'Cl', 'Br', 'Mg', 'Na', 'Ca', 'Fe', 'Al', 'I', 'B', 'K', 'Se', 'Zn', 'H', 'Cu', 'Mn', 'unknown'] BTYPE_L...
4,576
27.968354
144
py
rxngenerator
rxngenerator-master/rxnft_vae/trainvae.py
import torch import torch.nn as nn import torch.optim as optim import torch.optim.lr_scheduler as lr_scheduler from torch.utils.data import DataLoader from torch.autograd import Variable import math, random, sys from optparse import OptionParser from collections import deque from reaction_utils import read_multistep_...
8,329
34.751073
184
py
rxngenerator
rxngenerator-master/rxnft_vae/vae.py
import torch import torch.nn as nn from nnutils import create_var, attention from ftencoder import FTEncoder from ftdecoder import FTDecoder from rxndecoder import RXNDecoder, RXNDecoder1 from rxnencoder import RXNEncoder from mpn import MPN,PP,Discriminator def set_batch_nodeID(ft_trees, ft_vocab): tot = 0 for ft...
4,889
37.203125
176
py
rxngenerator
rxngenerator-master/rxnft_vae/rxnencoder.py
import rdkit import rdkit.Chem as Chem from reaction_utils import get_mol_from_smiles, get_smiles_from_mol,read_multistep_rxns, get_template_order from reaction import ReactionTree, extract_starting_reactants, StartingReactants, Templates from collections import deque import torch import torch.nn as nn from nnutils imp...
4,282
28.136054
109
py
rxngenerator
rxngenerator-master/rxnft_vae/ftencoder.py
import torch import torch.nn as nn from nnutils import create_var, GRU from fragment import FragmentVocab, FragmentTree from collections import deque MAX_NB = 16 device = torch.device("cuda:0") class FTEncoder(nn.Module): def __init__(self, ftvocab, hidden_size, embedding=None): super(FTEncoder, self).__init__(...
3,860
26.776978
77
py
rxngenerator
rxngenerator-master/reaction_trees_creator/retro_star/api.py
import torch import logging import time from retro_star.common import prepare_starting_molecules, prepare_mlp, \ prepare_molstar_planner, smiles_to_fp from retro_star.model import ValueMLP from retro_star.utils import setup_logger import os dirpath = os.path.dirname(os.path.abspath(__file__)) class RSPlanner: ...
2,839
32.023256
90
py
rxngenerator
rxngenerator-master/reaction_trees_creator/retro_star/run_to_create_reaction_trees.py
import numpy as np import torch import random import logging import time import pickle import os from retro_star.common import args, prepare_starting_molecules, prepare_mlp, \ prepare_molstar_planner, smiles_to_fp from retro_star.model import ValueMLP from retro_star.api import RSPlanner import rdkit.Chem as Chem...
1,946
26.422535
107
py
rxngenerator
rxngenerator-master/reaction_trees_creator/retro_star/data_loader/value_data_loader.py
import os import numpy as np import torch import pickle import logging from torch.utils.data import Dataset, DataLoader def unpack_fps(packed_fps): # packed_fps = np.array(packed_fps) shape = (*(packed_fps.shape[:-1]), -1) fps = np.unpackbits(packed_fps.reshape((-1, packed_fps.shape[-1])), ...
2,887
34.219512
79
py
rxngenerator
rxngenerator-master/reaction_trees_creator/retro_star/common/parse_args.py
import argparse import os import torch import sys parser = argparse.ArgumentParser() # ===================== gpu id ===================== # parser.add_argument('--gpu', type=int, default=-1) # =================== random seed ================== # parser.add_argument('--seed', type=int, default=1234) # =============...
2,262
38.017241
78
py
rxngenerator
rxngenerator-master/reaction_trees_creator/retro_star/packages/mlp_retrosyn/mlp_retrosyn/mlp_inference.py
from __future__ import print_function import numpy as np import torch import torch.nn.functional as F from rdkit import Chem import rdchiral from rdchiral.main import rdchiralRunText, rdchiralRun from rdchiral.initialization import rdchiralReaction, rdchiralReactants from .mlp_policies import load_parallel_model , prep...
4,318
38.990741
109
py
rxngenerator
rxngenerator-master/reaction_trees_creator/retro_star/packages/mlp_retrosyn/mlp_retrosyn/mlp_policies.py
import os import random import numpy as np from time import gmtime, strftime, localtime import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F from torch.utils.data import Dataset, DataLoader from rdkit import Chem, DataStructs from rdkit.Chem import AllChem from tqdm import tqdm...
14,193
36.254593
119
py
rxngenerator
rxngenerator-master/reaction_trees_creator/retro_star/model/value_mlp.py
import torch import torch.nn as nn import torch.nn.functional as F import logging class ValueMLP(nn.Module): def __init__(self, n_layers, fp_dim, latent_dim, dropout_rate, device): super(ValueMLP, self).__init__() self.n_layers = n_layers self.fp_dim = fp_dim self.latent_dim = late...
1,306
31.675
81
py
DMF
DMF-main/train.py
from utils.logger import setup_logger from datasets import make_dataloader, make_dataloader_cross from model.make_model import make_model_cross from solver import make_optimizer from solver.scheduler_factory import create_scheduler from loss import make_loss from processor import do_train, do_train_cross import random ...
3,120
29.90099
119
py
DMF
DMF-main/solver/lr_scheduler.py
# encoding: utf-8 """ @author: liaoxingyu @contact: sherlockliao01@gmail.com """ from bisect import bisect_right import torch # FIXME ideally this would be achieved with a CombinedLRScheduler, # separating MultiStepLR with WarmupLR # but the current LRScheduler design doesn't allow it class WarmupMultiStepLR(torch....
1,862
31.684211
80
py
DMF
DMF-main/solver/cosine_lr.py
""" Cosine Scheduler Cosine LR schedule with warmup, cycle/restarts, noise. Hacked together by / Copyright 2020 Ross Wightman """ import logging import math import torch from .scheduler import Scheduler _logger = logging.getLogger(__name__) class CosineLRScheduler(Scheduler): """ Cosine decay with restar...
3,958
33.12931
121
py
DMF
DMF-main/solver/scheduler.py
from typing import Dict, Any import torch class Scheduler: """ Parameter Scheduler Base Class A scheduler base class that can be used to schedule any optimizer parameter groups. Unlike the builtin PyTorch schedulers, this is intended to be consistently called * At the END of each epoch, before incre...
4,750
43.820755
112
py
DMF
DMF-main/solver/make_optimizer.py
import torch def make_optimizer(cfg, model, center_criterion): params = [] for key, value in model.named_parameters(): if not value.requires_grad: continue lr = cfg.SOLVER.BASE_LR weight_decay = cfg.SOLVER.WEIGHT_DECAY if "bias" in key: lr = cfg.SOLVER.B...
1,215
39.533333
106
py
DMF
DMF-main/processor/processor.py
import logging import os import time import torch import torch.nn as nn from utils.meter import AverageMeter from utils.metrics import R1_mAP_eval from torch.cuda import amp import torch.distributed as dist def do_train(cfg, model, center_criterion, train_loader, val...
12,172
40.264407
122
py
DMF
DMF-main/datasets/make_dataloader.py
import torch import torchvision.transforms as T from torch.utils.data import DataLoader from .bases import ImageDataset, ImageDataset_cross from timm.data.random_erasing import RandomErasing from .sampler import RandomIdentitySampler from .dukemtmcreid import DukeMTMCreID from .market1501 import Market1501 from .msmt1...
7,810
40.994624
123
py
DMF
DMF-main/datasets/sampler.py
from torch.utils.data.sampler import Sampler from collections import defaultdict import copy import random import numpy as np class RandomIdentitySampler(Sampler): """ Randomly sample N identities, then for each identity, randomly sample K instances, therefore batch size is N*K. Args: - data_source...
2,433
34.794118
84
py
DMF
DMF-main/datasets/sampler_ddp.py
from torch.utils.data.sampler import Sampler from collections import defaultdict import copy import random import numpy as np import math import torch.distributed as dist _LOCAL_PROCESS_GROUP = None import torch import pickle def _get_global_gloo_group(): """ Return a process group based on gloo backend, conta...
7,051
34.616162
167
py
DMF
DMF-main/datasets/bases.py
from PIL import Image, ImageFile from torch.utils.data import Dataset import os.path as osp import random import torch ImageFile.LOAD_TRUNCATED_IMAGES = True import random def read_image(img_path): """Keep reading image until succeed. This can avoid IOError incurred by heavy IO process.""" got_img = False...
3,650
33.443396
112
py
DMF
DMF-main/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 import subprocess import sys from setuptools import Extension, find_packages, setup from torch.utils import ...
7,589
28.648438
92
py
DMF
DMF-main/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. """isort:skip_file""" import functools import importlib dependencies = [ "dataclasses", "hydra", "numpy", "omegaconf", "...
2,099
27.378378
82
py
DMF
DMF-main/fairseq/examples/truncated_bptt/transformer_xl_model.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 dataclasses import dataclass, field from typing import Dict, List, Optional import torch from fairseq.dataclass import Fa...
4,738
31.909722
84
py
DMF
DMF-main/fairseq/examples/truncated_bptt/truncated_bptt_lm_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 logging import os from dataclasses import dataclass, field from typing import List, Optional, Tuple import torch from fairseq import u...
9,995
33.951049
86
py
DMF
DMF-main/fairseq/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,151
38.73444
98
py
DMF
DMF-main/fairseq/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.models.transformer import TransformerEncoder from .linformer_sentence_encoder_layer import Li...
2,151
38.127273
85
py
DMF
DMF-main/fairseq/examples/linformer/linformer_src/modules/linformer_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 from fairseq import utils from fairseq.modules import TransformerEncoderLayer from .multihead_linear_attention import MultiheadL...
2,743
40.575758
85
py
DMF
DMF-main/fairseq/examples/linformer/linformer_src/models/linformer_roberta.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. """ Linformer: Self-Attention with Linear Complexity """ import logging import torch from fairseq import utils from fairseq.models import reg...
4,143
33.247934
84
py
DMF
DMF-main/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 flashlight (previously called wav2letter++) dataset """ import argpa...
7,680
29.601594
99
py
DMF
DMF-main/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 flashlight (previously called wav2letter++) dataset """ import argpa...
7,020
27.084
135
py
DMF
DMF-main/fairseq/examples/wav2vec/xlsr/scripts/gen_audio_embedding.py
""" Usage: This script is used to extract the embedding / logit for speech classification task. 1. Set fdir into your model checkpoint directory 2. Run the following command (preferrably on GPU machine to speed up the inference process) CUDA_VISIBLE_DEVICES=0 python3 examples/wav2vec/gen_audio_embeddin...
9,209
40.300448
246
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/w2vu_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. """ Run inference for pre-processed data with a trained model. """ import ast from collections import namedtuple fr...
22,454
30.405594
129
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/models/wav2vec_u.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 dataclasses import dataclass from enum import Enum, auto import math import numpy as np from typing import Tuple, List, Optional, Dict i...
22,945
32.351744
87
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/scripts/wav2vec_apply_cluster_faiss.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 os import os.path as osp import numpy as np import tqdm import torch import sys import faiss...
4,015
30.131783
129
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/scripts/merge_clusters.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 os import os.path as osp import numpy as np import tqdm import torch import random from shuti...
3,543
29.817391
110
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/scripts/remove_silence.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. """ get intervals from .vads file, specify output data, and this script removes silences and saves the audio data in...
1,927
29.125
128
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/scripts/apply_pca.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 os import os.path as osp import math import numpy as np import tqdm import torch from shutil ...
2,496
31.428571
114
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/scripts/wav2vec_cluster_faiss.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 gc import os import os.path as osp import random import numpy as np import tqdm import torch ...
6,315
28.933649
129
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/scripts/mean_pool.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 os import os.path as osp import math import numpy as np import tqdm import torch import torch...
3,187
30.88
144
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/scripts/wav2vec_extract_features.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 os import os.path as osp import tqdm import torch import torch.nn.functional as F from shutil...
3,673
29.616667
105
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/data/extracted_features_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 logging import os import contextlib import numpy as np import torch from fairseq.data import FairseqDataset, data_utils logger = l...
5,038
28.994048
87
py
DMF
DMF-main/fairseq/examples/wav2vec/unsupervised/tasks/unpaired_audio_text.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 dataclasses import dataclass,...
15,658
33.567329
102
py
DMF
DMF-main/fairseq/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,473
33.762791
90
py
DMF
DMF-main/fairseq/examples/speech_to_speech/generate_waveform_from_code.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 logging from pathlib import Path import random import soundfile as sf import torch from tqdm import tqdm ...
3,285
27.08547
107
py
DMF
DMF-main/fairseq/examples/speech_to_speech/benchmarking/core.py
import timeit import logging import torch from pypapi import events, papi_high as high from memory_profiler import memory_usage from torch import nn from argparse import Namespace from fairseq.dataclass.utils import convert_namespace_to_omegaconf from fairseq.data import data_utils as fairseq_data_utils from fairseq im...
17,782
35.440574
131
py
DMF
DMF-main/fairseq/examples/speech_to_speech/benchmarking/data_utils.py
from fairseq import tasks import numpy as np import logging import random from fairseq import options import torch import os import soundfile as sf from fairseq.data.audio.audio_utils import ( get_waveform, parse_path, ) logging.basicConfig() logging.root.setLevel(logging.INFO) logging.basicConfig(level=loggi...
7,893
28.788679
127
py
DMF
DMF-main/fairseq/examples/speech_to_speech/benchmarking/get_metrics.py
import copy import torch import logging from argparse import Namespace import yaml from fairseq import options from examples.speech_to_speech.benchmarking.core import ( Processing, SpeechGeneration, Cascaded2StageS2ST, Cascaded3StageS2ST, S2UT, ) from examples.speech_to_speech.benchmarking.data_util...
5,053
30.006135
115
py
DMF
DMF-main/fairseq/examples/speech_to_speech/unity/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 sys from typing import Dict, List, Optional import torch from torch import Tensor from fairseq.sequence_generator import ...
25,480
39.639553
107
py
DMF
DMF-main/fairseq/examples/speech_to_speech/unity/sequence_generator_multi_decoder.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, List, Optional import torch import torch.nn as nn from torch import Tensor from fairseq import search class Multi...
9,797
36.54023
95
py
DMF
DMF-main/fairseq/examples/speech_to_speech/preprocessing/prep_s2spect_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 from pathlib import Path import shutil import torchaudio import soundfile as ...
5,844
33.382353
125
py
DMF
DMF-main/fairseq/examples/bart/summarize.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.models.bart import BARTModel import argparse XSUM_KWARGS = dict(beam=6, lenpen=1.0, max_len_b=60, min_len=10, no_re...
3,174
30.435644
88
py
DMF
DMF-main/fairseq/examples/data2vec/models/data2vec_audio.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 math from dataclasses import dataclass, field from typing import Optional from omegaconf import II import torch import...
17,916
32.302974
104
py
DMF
DMF-main/fairseq/examples/data2vec/models/data2vec_text.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 dataclasses import dataclass, field from typing import Optional import logging import math import torch import torch.nn as nn import tor...
18,697
35.096525
104
py
DMF
DMF-main/fairseq/examples/adaptive_span/adaptive_span_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 class AdaptiveMask(nn.Module): """Soft masking function f...
5,881
35.534161
85
py
DMF
DMF-main/fairseq/examples/adaptive_span/adagrad_with_grad_clip.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 torch.optim import Adagrad from fairseq.optim import LegacyFairseqOptimizer, register_optimizer @register_optimizer("adagrad_with_grad...
4,374
32.914729
92
py
DMF
DMF-main/fairseq/examples/adaptive_span/adaptive_span_model.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the 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.modules.layer_norm import Lay...
8,540
31.352273
87
py
DMF
DMF-main/fairseq/examples/adaptive_span/adaptive_span_loss.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 dataclasses import dataclass import torch.nn.functional as F from fairseq import metrics, utils from fairseq.criterions impo...
4,233
38.570093
88
py
DMF
DMF-main/fairseq/examples/adaptive_span/adaptive_span_model_wrapper.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 dataclasses import dataclass from typing import Dict, List, Optional import torch from fairseq.dataclass import FairseqDa...
4,692
31.143836
114
py
DMF
DMF-main/fairseq/examples/MMPT/setup.py
import setuptools with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="mmpt", version="0.0.1", author="Hu Xu, Po-yao Huang", author_email="huxu@fb.com", description="A package for multimodal pretraining.", long_description=long_description, long_descr...
668
25.76
59
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt_cli/predict.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 glob import argparse import pprint import omegaconf from omegaconf import OmegaConf from torch.utils.data import DataLoader ...
3,937
33.54386
81
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/modules/mm.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
5,537
36.931507
83
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/modules/vectorpool.py
# Copyright (c) Facebook, Inc. All Rights Reserved import torch import os import numpy as np import pickle from . import retri from ..utils import get_local_rank class VectorPool(object): """ Base class of retrieval space. """ def __init__(self, config): from transformers import AutoConfig ...
8,278
32.518219
82
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/models/transformermodel.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
26,064
34.462585
87
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/models/mmfusionnlg.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors, Facebook AI Research 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 L...
48,394
47.395
246
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/models/mmfusion.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
30,634
32.047465
90
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/datasets/fairseqmmdataset.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. """ TODO (huxu): fairseq wrapper class for all dataset you defined: mostly MMDataset. """ from collections import OrderedDict from torch.util...
1,785
29.793103
85
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/datasets/mmdataset.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 collections import OrderedDict from torch.utils.data import Dataset from torch.utils.data.dataloader import default_collat...
3,873
33.589286
76
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/evaluators/predictor.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 random import json import numpy as np import torch import pickle import math from tqdm import tqdm class Predictor(object):...
23,125
37.802013
113
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/processors/how2processor.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
32,302
35.377252
88
py
DMF
DMF-main/fairseq/examples/MMPT/mmpt/processors/processor.py
# Copyright (c) Facebook, Inc. All Rights Reserved import numpy as np import os import torch class Processor(object): """ A generic processor for video (codec, feature etc.) and text. """ def __call__(self, **kwargs): raise NotImplementedError class MetaProcessor(Processor): """ A ...
9,358
33.032727
86
py