repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
NSVF | NSVF-main/fairnr/modules/renderer.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 collections import defaultdict
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairnr.modules.modul... | 12,718 | 44.102837 | 141 | py |
NSVF | NSVF-main/fairnr/modules/reader.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 random, os, glob
from fairnr.data.geometry import get_ray_direction, r6d2mat
torch.autograd.set_de... | 7,959 | 42.736264 | 125 | py |
NSVF | NSVF-main/fairnr/modules/field.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 torch.autograd import grad
from collections import Order... | 21,863 | 45.322034 | 131 | py |
NSVF | NSVF-main/fairnr/modules/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 torch
import torch.nn as nn
import torch.nn.functional as F
import torch.distributed as dist
import numpy as np
import math
import sys... | 49,252 | 45.377589 | 157 | py |
NSVF | NSVF-main/fairnr/modules/__init__.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 importlib
import os
# automatically import any Python files in the models/ directory
models_dir = os.path.dirname(__file__)
for file i... | 651 | 42.466667 | 111 | py |
NSVF | NSVF-main/fairnr/modules/hyper.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.
'''
Pytorch implementations of hyper-network modules.
This code is largely adapted from
https://github.com/vsitzmann/scene-representation-net... | 8,327 | 32.991837 | 125 | py |
NSVF | NSVF-main/fairnr/modules/module_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 math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.modules import LayerNorm
from fairseq.utils impor... | 5,337 | 31.54878 | 125 | py |
NSVF | NSVF-main/fairnr/modules/implicit.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.utils import get_activation_fn
from fairnr.modules.hyper impo... | 6,163 | 34.837209 | 111 | py |
NSVF | NSVF-main/fairnr/criterions/rendering_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
import torch.nn.functional as F
import torch
from torch import Tensor
from fairseq import metrics
from fairseq.utils import ite... | 9,677 | 43.805556 | 122 | py |
NSVF | NSVF-main/fairnr/criterions/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
import torch.nn.functional as F
TINY = 1e-7
def rgb_loss(predicts, rgbs, masks=None, L1=False, sum=False):
if masks is no... | 971 | 26 | 65 | py |
NSVF | NSVF-main/fairnr/criterions/__init__.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 importlib
import os
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith(".py") and not file.startswith("_"):
... | 458 | 29.6 | 65 | py |
NSVF | NSVF-main/fairnr/criterions/perceptual_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 torch
import torchvision
class VGGPerceptualLoss(torch.nn.Module):
def __init__(self, resize=False):
super(VGGPerceptualLo... | 2,023 | 39.48 | 103 | py |
NSVF | NSVF-main/fairnr/models/nsvf_bg.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
logger = logging.getLogger(__name__)
import cv2, math, time, copy, json
import numpy as np
from collections import defaultdict... | 7,079 | 43.810127 | 144 | py |
NSVF | NSVF-main/fairnr/models/multi_nsvf.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
logger = logging.getLogger(__name__)
import torch
from fairseq.models import (
register_model,
register_model_archite... | 1,938 | 30.786885 | 89 | py |
NSVF | NSVF-main/fairnr/models/nerf.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
logger = logging.getLogger(__name__)
import cv2, math, time
import numpy as np
from collections import defaultdict
import to... | 9,380 | 43.25 | 117 | py |
NSVF | NSVF-main/fairnr/models/fairnr_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.
"""
Base classes for various models.
The basic principle of differentiable rendering is two components:
-- an field or so-called geometri... | 14,302 | 41.19174 | 121 | py |
NSVF | NSVF-main/fairnr/models/nsvf.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
logger = logging.getLogger(__name__)
import cv2, math, time
import numpy as np
from collections import defaultdict
import tor... | 14,499 | 43.072948 | 135 | py |
NSVF | NSVF-main/fairnr/models/nmf.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
logger = logging.getLogger(__name__)
import torch
from fairseq.models import (
register_model,
register_model_architec... | 3,148 | 36.939759 | 92 | py |
NSVF | NSVF-main/fairnr/models/__init__.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 importlib
import os
# automatically import any Python files in the models/ directory
models_dir = os.path.dirname(__file__)
for file i... | 651 | 39.75 | 111 | py |
NSVF | NSVF-main/fairnr/clib/__init__.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.
''' Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch '''
from __future__ import (
division,
absolute_import,
w... | 14,842 | 37.553247 | 110 | py |
NSVF | NSVF-main/fairnr/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
import functools
import cv2
import math
import numpy as np
import imageio
from glob import glob
import os
import copy
import shut... | 11,063 | 28.902703 | 125 | py |
NSVF | NSVF-main/fairnr/data/shape_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, glob
import copy
import numpy as np
import torch
import logging
from collections import defaultdict
from fairseq.data import Fairs... | 20,801 | 36.821818 | 141 | py |
NSVF | NSVF-main/fairnr/data/geometry.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 numpy as np
import torch
import torch.nn.functional as F
from fairnr.data import data_utils as D
try:
from fairnr.clib._ext import... | 11,984 | 33.941691 | 112 | py |
NSVF | NSVF-main/fairnr/data/__init__.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 .shape_dataset import (
ShapeDataset, ShapeViewDataset, ShapeViewStreamDataset,
SampledPixelDataset, WorldCoordDataset,
Infin... | 474 | 24 | 65 | py |
NSVF | NSVF-main/fairnr/data/trajectory.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 numpy as np
TRAJECTORY_REGISTRY = {}
def register_traj(name):
def register_traj_fn(fn):
if name in TRAJECTO... | 2,045 | 34.894737 | 130 | py |
NSVF | NSVF-main/fairnr/tasks/__init__.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 importlib
import os
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith('.py') and not file.startswith('_'):
... | 420 | 31.384615 | 65 | py |
NSVF | NSVF-main/fairnr/tasks/neural_rendering.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, copy
import json
import torch
import imageio
import numpy as np
from collections import defaultdict
from torchvision.utils import s... | 17,291 | 50.159763 | 114 | py |
NSVF | NSVF-main/fairnr_cli/render.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.
"""
This is a copy of fairseq-generate while simpler for other usage.
"""
import logging
import math
import os
impo... | 3,570 | 28.03252 | 96 | py |
NSVF | NSVF-main/fairnr_cli/render_multigpu.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.
"""
This is a copy of fairseq-generate while simpler for other usage.
"""
import logging
import math
import os
impo... | 4,399 | 29.985915 | 98 | py |
NSVF | NSVF-main/fairnr_cli/validate.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 logging
import sys
import numpy as np
import torch
from itertools import chain
from fairseq import checkpoin... | 5,384 | 33.082278 | 102 | py |
NSVF | NSVF-main/fairnr_cli/extract.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.
"""
This code is used for extact voxels/meshes from the learne model
"""
import logging
import numpy as np
import tor... | 3,180 | 38.7625 | 127 | py |
NSVF | NSVF-main/fairnr_cli/launch_slurm.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 random, shlex
import os, sys, subprocess
def launch_cluster(slurm_args, model_args):
# prepare
jobna... | 4,727 | 32.771429 | 99 | py |
NSVF | NSVF-main/fairnr_cli/__init__.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.
| 177 | 34.6 | 65 | py |
NSVF | NSVF-main/fairnr_cli/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.
This file is mostly copied from the original fairseq code
"""
... | 13,414 | 34.489418 | 117 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite1/generate.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
T=10
s=10
save1=randint(s,size=(T,s))
save2=randint(s,size=(T,s))
np.savetxt("mdp/S1",save1)
np.savetxt("mdp/S2",save2)
| 297 | 17.625 | 33 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite1/finite.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
import os
from multiprocessing import Process
#generate MDP
T=100
size=10
nS=size*size
nA=4
alpha=20
N=50000 #no of episodes
P=np.zeros((T,nS,n... | 4,541 | 23.159574 | 98 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite3/generate.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
T=20
s=10
save1=randint(s,size=(T,s))
save2=randint(s,size=(T,s))
np.savetxt("mdp/S1",save1)
np.savetxt("mdp/S2",save2)
| 297 | 17.625 | 33 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite3/finite.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
import os
from multiprocessing import Process
#generate MDP
T=100
size=10
nS=size*size
nA=4
alpha=20
N=50000 #no of episodes
P=np.zeros((T,nS,n... | 4,533 | 23.117021 | 98 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite_c3/generate.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
T=20
s=10
save1=randint(s,size=(T,s))
save2=randint(s,size=(T,s))
np.savetxt("mdp/S1",save1)
np.savetxt("mdp/S2",save2)
| 297 | 17.625 | 33 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite_c3/finite.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
import os
from multiprocessing import Process
#generate MDP
T=100
size=10
nS=size*size
nA=4
alpha=20
N=500000 #no of episodes
P=np.zeros((T,nS,... | 4,535 | 23.12766 | 98 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite_c2/generate.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
T=100
s=10
save1=randint(s,size=(T,s))
save2=randint(s,size=(T,s))
np.savetxt("mdp/S1",save1)
np.savetxt("mdp/S2",save2)
| 298 | 17.6875 | 33 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite_c2/finite.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
import os
from multiprocessing import Process
#generate MDP
T=100
size=10
nS=size*size
nA=4
alpha=20
N=500000 #no of episodes
P=np.zeros((T,nS,... | 4,537 | 23.138298 | 98 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite_c1/generate.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
T=10
s=10
save1=randint(s,size=(T,s))
save2=randint(s,size=(T,s))
np.savetxt("mdp/S1",save1)
np.savetxt("mdp/S2",save2)
| 297 | 17.625 | 33 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite_c1/finite.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
import os
from multiprocessing import Process
#generate MDP
T=100
size=10
nS=size*size
nA=4
alpha=20
N=500000 #no of episodes
P=np.zeros((T,nS,... | 4,543 | 23.170213 | 98 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite2/generate.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
T=100
s=10
save1=randint(s,size=(T,s))
save2=randint(s,size=(T,s))
np.savetxt("mdp/S1",save1)
np.savetxt("mdp/S2",save2)
| 298 | 17.6875 | 33 | py |
Finite-Horizon-with-constraints | Finite-Horizon-with-constraints-master/finite2/finite.py | import numpy as np
from numpy.random import choice
from numpy.random import randint
from scipy.special import softmax
from collections import deque
from random import sample
import os
from multiprocessing import Process
#generate MDP
T=100
size=10
nS=size*size
nA=4
alpha=20
N=50000 #no of episodes
P=np.zeros((T,nS,n... | 4,535 | 23.12766 | 98 | py |
penneysgame | penneysgame-master/conway.py | #!/usr/bin/env python
'''
conway.py: For solving generalized Penney's game with
generalized Conway formula, including simulations.
For background, see Miller(2019) ''
'''
import numpy as np
__author__ = "Joshua B. Miller"
__copyright__ = "Creative Commons"
__credits__ = "none"
__license__ = "GPL"
__version__ = ... | 7,370 | 35.490099 | 102 | py |
RegularizedBN | RegularizedBN-main/inference.py | from fairseq.models.roberta import RobertaModel
roberta = RobertaModel.from_pretrained(
'./checkpoints/transformer_roberta_large_rte/',
checkpoint_file='checkpoint_best.pt',
data_name_or_path='RTE-bin'
)
label_fn = lambda label: roberta.task.label_dictionary.string(
[label + roberta.task.label_dictiona... | 914 | 34.192308 | 92 | py |
RegularizedBN | RegularizedBN-main/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,389 | 25.768293 | 101 | py |
RegularizedBN | RegularizedBN-main/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 |
RegularizedBN | RegularizedBN-main/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.
"""
Legacy entry point. Use fairseq_cli/train.py or fairseq-train instead.
"""
from fairseq_cli.train import cli_mai... | 366 | 23.466667 | 70 | py |
RegularizedBN | RegularizedBN-main/examples/__init__.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.
__version__ = '0.9.0'
import examples.noisychannel # noqa
| 238 | 25.555556 | 65 | py |
RegularizedBN | RegularizedBN-main/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,714 | 29.737052 | 111 | py |
RegularizedBN | RegularizedBN-main/examples/wav2vec/wav2vec_manifest.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.
"""
Data pre-processing: build vocabularies and binarize training data.
"""
import argparse
import glob
import os
impor... | 2,176 | 37.192982 | 114 | py |
RegularizedBN | RegularizedBN-main/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 | 29.004219 | 135 | py |
RegularizedBN | RegularizedBN-main/examples/wav2vec/libri_labels.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 os
def main():
... | 1,836 | 31.22807 | 83 | py |
RegularizedBN | RegularizedBN-main/examples/backtranslation/extract_bt_data.py | #!/usr/bin/env python
# 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 fileinput
from tqdm import tqdm
def main():
parser = argparse.ArgumentParser(description=(... | 2,363 | 38.4 | 107 | py |
RegularizedBN | RegularizedBN-main/examples/backtranslation/deduplicate_lines.py | #!/usr/bin/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 fileinput
import hashlib
from multiprocessing import Pool
import sys
def get_hashes_and_lines(raw_... | 1,221 | 28.095238 | 68 | py |
RegularizedBN | RegularizedBN-main/examples/translation_moe/score.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.
"""
Scoring script for computing pairwise BLEU and multi-ref BLEU over a set of
candidate hypotheses.
See `"Mixture Mod... | 6,101 | 30.61658 | 90 | py |
RegularizedBN | RegularizedBN-main/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 |
RegularizedBN | RegularizedBN-main/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 |
RegularizedBN | RegularizedBN-main/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,137 | 40.348416 | 107 | py |
RegularizedBN | RegularizedBN-main/examples/translation_moe/src/__init__.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 . import translation_moe # noqa
| 216 | 30 | 65 | py |
RegularizedBN | RegularizedBN-main/examples/unsupervised_quality_estimation/repeat_lines.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
def _normalize_spaces(line):
return ' '.join(line.split())
def main():
parser = argparse.ArgumentParser... | 828 | 27.586207 | 76 | py |
RegularizedBN | RegularizedBN-main/examples/unsupervised_quality_estimation/aggregate_scores.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 numpy as np
import sys
aggregate_funcs = {
'std': np.std,
'var': np.var,
'median': np.median,
'mean':... | 1,135 | 26.707317 | 83 | py |
RegularizedBN | RegularizedBN-main/examples/unsupervised_quality_estimation/meteor.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 sys
import subprocess
import tempfile
import math
from itertools import combinations
from collections import... | 3,318 | 32.867347 | 107 | py |
RegularizedBN | RegularizedBN-main/examples/roberta/preprocess_RACE.py | #!/usr/bin/env python
# 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 argparse
import json
import os
import re
class InputExample:
def __init__(self, paragrap... | 3,395 | 32.96 | 107 | py |
RegularizedBN | RegularizedBN-main/examples/roberta/multiprocessing_bpe_encoder.py | #!/usr/bin/env python
# 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 argparse
import contextlib
import sys
from collections import Counter
from multiprocessing im... | 3,756 | 27.9 | 81 | py |
RegularizedBN | RegularizedBN-main/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 |
RegularizedBN | RegularizedBN-main/examples/roberta/commonsense_qa/__init__.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 . import commonsense_qa_task # noqa
| 220 | 30.571429 | 65 | py |
RegularizedBN | RegularizedBN-main/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 |
RegularizedBN | RegularizedBN-main/examples/roberta/wsc/wsc_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 functools import lru_cache
import json
def convert_sentence_to_json(sentence):
if '_' in sentence:
prefix, rest = sentence.... | 8,329 | 34.147679 | 94 | py |
RegularizedBN | RegularizedBN-main/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 |
RegularizedBN | RegularizedBN-main/examples/roberta/wsc/__init__.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 . import wsc_criterion # noqa
from . import wsc_task # noqa
| 245 | 29.75 | 65 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/__init__.py | from . import tasks, criterions, models # noqa
| 48 | 23.5 | 47 | py |
RegularizedBN | RegularizedBN-main/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 editdistance
import logging
import math
i... | 14,668 | 33.193473 | 147 | py |
RegularizedBN | RegularizedBN-main/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.
"""
from collections import namedtuple, deque
import gc
import itertools as it
import numpy ... | 14,872 | 33.269585 | 164 | py |
RegularizedBN | RegularizedBN-main/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 |
RegularizedBN | RegularizedBN-main/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 fairseq import utils
from fairseq.criterions import FairseqCriterion, register_criterion
from exampl... | 5,857 | 33.25731 | 85 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/criterions/__init__.py | import importlib
import os
# ASG loss requires wav2letter
files_to_skip = set()
try:
import wav2letter
except ImportError:
files_to_skip.add("ASG_loss.py")
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith(".py") and not file.startswith("_") and file not in files_to_skip:
criter... | 470 | 25.166667 | 87 | py |
RegularizedBN | RegularizedBN-main/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,043 | 35.786495 | 88 | py |
RegularizedBN | RegularizedBN-main/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 (
Fair... | 6,079 | 32.96648 | 87 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/models/__init__.py | import importlib
import os
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith('.py') and not file.startswith('_'):
model_name = file[:file.find('.py')]
importlib.import_module('examples.speech_recognition.models.' + model_name)
| 266 | 32.375 | 83 | py |
RegularizedBN | RegularizedBN-main/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
from collections import namedtuple
... | 3,670 | 36.845361 | 134 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/utils/wer_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.
from __future__ import absolute_import, division, print_function, unicode_literals
import re
from collections import ... | 11,842 | 30.002618 | 86 | py |
RegularizedBN | RegularizedBN-main/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,812 | 35.462121 | 84 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/data/replabels.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.
"""
Replabel transforms for use with wav2letter's ASG criterion.
"""
def replabel_symbol(i):
"""
Replabel sy... | 1,970 | 26.760563 | 82 | py |
RegularizedBN | RegularizedBN-main/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 |
RegularizedBN | RegularizedBN-main/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,870 | 33.5625 | 82 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/data/__init__.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 .asr_dataset import AsrDataset
__all__ = [
'AsrDataset',
]
| 247 | 21.545455 | 65 | py |
RegularizedBN | RegularizedBN-main/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 fairseq.data import Dictionary
from fairseq.tasks import FairseqTask, register_t... | 5,094 | 34.381944 | 97 | py |
RegularizedBN | RegularizedBN-main/examples/speech_recognition/tasks/__init__.py | import importlib
import os
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith('.py') and not file.startswith('_'):
task_name = file[:file.find('.py')]
importlib.import_module('examples.speech_recognition.tasks.' + task_name)
| 263 | 32 | 81 | py |
RegularizedBN | RegularizedBN-main/examples/byte_level_bpe/get_bitext.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.path as op
import argparse
import os
from multiprocessing import cpu_count
from collections import namedtuple
from typing import Op... | 7,743 | 36.410628 | 79 | py |
RegularizedBN | RegularizedBN-main/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,028 | 46.895238 | 87 | py |
RegularizedBN | RegularizedBN-main/examples/simultaneous_translation/__init__.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 . import criterions, models, eval # noqa
| 225 | 31.285714 | 65 | py |
RegularizedBN | RegularizedBN-main/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.functional as F
import torch.nn as nn
from fairseq import utils
from fairseq.modules import Multihe... | 21,349 | 35.125212 | 119 | py |
RegularizedBN | RegularizedBN-main/examples/simultaneous_translation/modules/monotonic_transformer_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.
from fairseq.modules import (
LayerNorm,
TransformerEncoderLayer,
TransformerDecoderLayer
)
from . import build_monotonic_attenti... | 1,919 | 32.103448 | 92 | py |
RegularizedBN | RegularizedBN-main/examples/simultaneous_translation/modules/__init__.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 importlib
import os
from fairseq import registry
(
build_monotonic_attention,
register_monotonic_attention,
MONOTONIC_ATTE... | 625 | 30.3 | 90 | py |
RegularizedBN | RegularizedBN-main/examples/simultaneous_translation/eval/evaluate.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 client import SimulSTEvaluationService, SimulSTLocalEvaluationService
from fairseq.registry import REGISTRIES
from agent... | 2,494 | 34.140845 | 77 | py |
RegularizedBN | RegularizedBN-main/examples/simultaneous_translation/eval/server.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
import json
from tornado import web, ioloop
from scorers import build_scorer
DEFAULT_HOSTNAME = 'localhost'
DEFAULT... | 2,458 | 27.929412 | 84 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.