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 |
|---|---|---|---|---|---|---|
Beyond-Task-Success-NAACL2019 | Beyond-Task-Success-NAACL2019-master/utils/datasets/GamePlay/GamePlayDataset.py | import os
import json
import numpy as np
import h5py
from PIL import Image
from utils.datasets.GamePlay.prepro import create_data_file
from torch.utils.data import Dataset
from torchvision import transforms
class GamePlayDataset(Dataset):
"""docstring for GameplayN2NResNet."""
def __init__(self, split, **kwarg... | 3,043 | 43.115942 | 211 | py |
Beyond-Task-Success-NAACL2019 | Beyond-Task-Success-NAACL2019-master/utils/datasets/GamePlay/prepro.py | import json
import torch
import collections
import os
import gzip
import io
import h5py
import numpy as np
from torch.utils.data import Dataset
from nltk.tokenize import TweetTokenizer
from utils.image_utils import get_spatial_feat
def create_data_file(data_dir, data_file, data_args, vocab_file_name, split):
"""Cr... | 5,052 | 35.352518 | 138 | py |
Beyond-Task-Success-NAACL2019 | Beyond-Task-Success-NAACL2019-master/utils/datasets/GamePlay/GameplayN2NResNetDataset.py | import os
import json
import numpy as np
import h5py
from PIL import Image
from utils.datasets.GamePlay.prepro import create_data_file
from torch.utils.data import Dataset
from torchvision import transforms
class GameplayN2NResNetDataset(Dataset):
"""docstring for GameplayN2NResNet."""
def __init__(self, split... | 3,608 | 43.012195 | 211 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/setup.py | from setuptools import setup
setup(
name="guided-diffusion",
py_modules=["guided_diffusion"],
install_requires=["blobfile>=1.0.5", "torch", "tqdm"],
)
| 164 | 19.625 | 58 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/scripts/image_train.py | """
Train a diffusion model on images.
"""
from torch.multiprocessing import Pool, Process, set_start_method
try:
set_start_method('spawn')
except RuntimeError:
pass
import argparse
import horovod.torch as hvd
from guided_diffusion import logger
from guided_diffusion.image_datasets import load_data
from guided... | 2,766 | 27.234694 | 86 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/scripts/image_sample.py | """
Generate a large batch of image samples from a model and save them as a large
numpy array. This can be used to produce samples for FID evaluation.
"""
import argparse
import os
import torch
import numpy as np
import torch as th
from guided_diffusion import logger
from guided_diffusion.script_util import (
NUM_... | 4,069 | 30.550388 | 105 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/scripts/super_res_sample.py | """
Generate a large batch of samples from a super resolution model, given a batch
of samples from a regular model from image_sample.py.
"""
import argparse
import os
import blobfile as bf
import numpy as np
import torch as th
import torch.distributed as dist
from guided_diffusion import dist_util, logger
from guide... | 3,671 | 30.118644 | 84 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/scripts/classifier_sample.py | """
Like image_sample.py, but use a noisy image classifier to guide the sampling
process towards more realistic images.
"""
import argparse
import os
import numpy as np
import torch as th
import torch.distributed as dist
import torch.nn.functional as F
from guided_diffusion import dist_util, logger
from guided_diffu... | 4,266 | 31.325758 | 88 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/scripts/compute_metric.py | """
Generate a large batch of image samples from a model and save them as a large
numpy array. This can be used to produce samples for FID evaluation.
"""
import argparse
import json
import os
import torch
import numpy as np
import torch as th
from guided_diffusion import logger
from guided_diffusion.script_util impor... | 10,635 | 34.453333 | 112 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/scripts/classifier_train.py | """
Train a noised image classifier on ImageNet.
"""
import argparse
import os
import blobfile as bf
import torch as th
import torch.distributed as dist
import torch.nn.functional as F
from torch.nn.parallel.distributed import DistributedDataParallel as DDP
from torch.optim import AdamW
from guided_diffusion import ... | 7,313 | 31.220264 | 99 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/scripts/image_nll.py | """
Approximate the bits/dimension for an image model.
"""
import argparse
import os
import numpy as np
import torch.distributed as dist
from guided_diffusion import dist_util, logger
from guided_diffusion.image_datasets import load_data
from guided_diffusion.script_util import (
model_and_diffusion_defaults,
... | 2,934 | 29.257732 | 86 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/scripts/super_res_train.py | """
Train a super-resolution model.
"""
import argparse
import torch.nn.functional as F
from guided_diffusion import dist_util, logger
from guided_diffusion.image_datasets import load_data
from guided_diffusion.resample import create_named_schedule_sampler
from guided_diffusion.script_util import (
sr_model_and_... | 2,695 | 26.232323 | 87 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/resample.py | from abc import ABC, abstractmethod
import numpy as np
import torch as th
import torch.distributed as dist
def create_named_schedule_sampler(name, diffusion):
"""
Create a ScheduleSampler from a library of pre-defined samplers.
:param name: the name of the sampler.
:param diffusion: the diffusion ob... | 5,689 | 35.709677 | 87 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/losses.py | """
Helpers for various likelihood-based losses. These are ported from the original
Ho et al. diffusion models codebase:
https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/utils.py
"""
import numpy as np
import torch as th
def normal_kl(mean1, logvar1, mean2, logvar... | 2,534 | 31.5 | 109 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/image_datasets.py | import math
import random
from PIL import Image
import blobfile as bf
import numpy as np
from torch.utils.data import DataLoader, Dataset
import horovod.torch as hvd
def load_data(
*,
data_dir,
batch_size,
image_size,
class_cond=False,
deterministic=False,
random_crop=False,
random_fli... | 6,517 | 35.413408 | 88 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/nn.py | """
Various utilities for neural networks.
"""
import math
import torch as th
import torch.nn as nn
# PyTorch 1.7 has SiLU, but we support PyTorch 1.5.
class SiLU(nn.Module):
def forward(self, x):
return x * th.sigmoid(x)
class GroupNorm32(nn.GroupNorm):
def forward(self, x):
return super(... | 5,108 | 28.194286 | 88 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/fp16_util.py | """
Helpers to train with 16-bit precision.
"""
import numpy as np
import torch as th
import torch.nn as nn
from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
from . import logger
INITIAL_LOG_LOSS_SCALE = 20.0
def convert_module_to_f16(l):
"""
Convert primitive modules to float16.
... | 7,925 | 32.443038 | 114 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/unet.py | from abc import abstractmethod
import math
import numpy as np
import torch as th
import torch.nn as nn
import torch.nn.functional as F
from .fp16_util import convert_module_to_f16, convert_module_to_f32
from .nn import (
checkpoint,
conv_nd,
linear,
avg_pool_nd,
zero_module,
normalization,
... | 31,367 | 33.776053 | 124 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/gaussian_diffusion.py | """
This code started out as a PyTorch port of Ho et al's diffusion models:
https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/diffusion_utils_2.py
Docstrings have been added, as well as DDIM sampling and a new collection of beta schedules.
"""
import enum
import mat... | 38,888 | 36.829767 | 129 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/train_util.py | import numpy as np
import time
import copy
import functools
import os
from glob import glob
import blobfile as bf
import torch as th
import torch.distributed as dist
from torch.nn.parallel.distributed import DistributedDataParallel as DDP
from torch.optim import AdamW
import torch
from . import logger
from .fp16_util ... | 11,066 | 34.245223 | 91 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/respace.py | import numpy as np
import torch as th
from .gaussian_diffusion import GaussianDiffusion
def space_timesteps(num_timesteps, section_counts):
"""
Create a list of timesteps to use from an original diffusion process,
given the number of timesteps we want to take from equally-sized portions
of the origin... | 5,315 | 39.272727 | 87 | py |
generative-models-for-highres-solar-images | generative-models-for-highres-solar-images-main/diffusion/guided_diffusion/dist_util.py | """
Helpers for distributed training.
"""
import io
import os
import socket
import blobfile as bf
from mpi4py import MPI
import torch as th
import torch.distributed as dist
# Change this to reflect your cluster layout.
# The GPU for a given rank is (rank % GPUS_PER_NODE).
GPUS_PER_NODE = 8
SETUP_RETRY_COUNT = 3
d... | 1,959 | 22.614458 | 77 | py |
CFN | CFN-main/intrinsic_motivation/intrinsic_rewards.py | # coding=utf-8
# Copyright 2021 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 68,744 | 42.046337 | 167 | py |
CFN | CFN-main/cc_intrinsic_motivation/run_experiment.py | # coding=utf-8
# Copyright 2021 The Dopamine Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 7,486 | 36.248756 | 130 | py |
CFN | CFN-main/cc_intrinsic_motivation/exploration_runner.py | import os
import gin
import time
import pickle
import gzip
import numpy as np
from absl import logging
from copy import deepcopy
from collections import defaultdict
from flax.metrics import tensorboard
from dopamine.discrete_domains import iteration_statistics
from dopamine.discrete_domains import gym_lib
from dopamin... | 12,941 | 39.068111 | 137 | py |
CFN | CFN-main/cc_intrinsic_motivation/intrinsic_SAC.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from dopamine.jax.agents.sac import sac_agent as base_sac_agent
import numpy as np
import tensorflow.compat.v1 as tf
from bonus_based_exploration.intrinsic_motivation import intrinsic_rewards
from dopamine.jax ... | 7,413 | 36.826531 | 101 | py |
CFN | CFN-main/cc_intrinsic_motivation/train.py | # coding=utf-8
# Copyright 2021 The Dopamine Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 3,190 | 33.311828 | 101 | py |
CFN | CFN-main/gridworld/sensors.py | import numpy as np
import scipy.ndimage.filters
import scipy.ndimage
import scipy.stats
def get_truncated_normal(mean=0, sd=1.0, low=-1, upp=1):
return scipy.stats.truncnorm((low - mean) / sd, (upp - mean) / sd, loc=mean, scale=sd)
class NullSensor:
def observe(self, s):
return s
class MultiplySenso... | 6,924 | 31.209302 | 96 | py |
tevatron | tevatron-main/examples/splade/train_splade.py | import logging
import os
import sys
import torch
from transformers import AutoConfig, AutoTokenizer
from transformers import (
HfArgumentParser,
set_seed,
)
from dataclasses import dataclass, field
from tevatron.arguments import ModelArguments, DataArguments, TevatronTrainingArguments
from tevatron.data import... | 4,554 | 32.740741 | 133 | py |
tevatron | tevatron-main/examples/splade/encode_splade.py | import logging
import os
import pickle
import sys
from contextlib import nullcontext
import numpy as np
from tqdm import tqdm
import torch
import json
from torch.utils.data import DataLoader
from transformers import AutoConfig, AutoTokenizer
from transformers import (
HfArgumentParser,
)
from tevatron.arguments... | 5,504 | 39.182482 | 127 | py |
tevatron | tevatron-main/examples/reranker/reranker_inference.py | import logging
import os
import pickle
import sys
from contextlib import nullcontext
from unittest import result
import numpy as np
from tqdm import tqdm
import torch
from torch.utils.data import DataLoader
from transformers import AutoConfig, AutoTokenizer
from transformers import (
HfArgumentParser,
)
from tev... | 3,946 | 35.211009 | 138 | py |
tevatron | tevatron-main/examples/reranker/reranker_train.py | import logging
import os
import sys
import torch
from transformers import AutoConfig, AutoTokenizer
from transformers import (
HfArgumentParser,
set_seed,
)
from tevatron.arguments import ModelArguments, DataArguments, \
TevatronTrainingArguments as TrainingArguments
from tevatron.reranker.modeling import... | 3,727 | 33.201835 | 133 | py |
tevatron | tevatron-main/examples/distill/distil_train.py | import logging
import os
import sys
import torch
from transformers import AutoConfig, AutoTokenizer
from transformers import (
HfArgumentParser,
set_seed,
)
from tevatron.arguments import DataArguments
from tevatron.modeling import DenseModel
from tevatron.reranker.modeling import RerankerModel
from tevatron.... | 4,662 | 35.147287 | 133 | py |
tevatron | tevatron-main/examples/unicoil/encode_unicoil.py | import json
import logging
import os
import sys
from contextlib import nullcontext
import numpy as np
from tqdm import tqdm
import torch
from torch.utils.data import DataLoader
from transformers import AutoConfig, AutoTokenizer
from transformers import (
HfArgumentParser,
)
from tevatron.arguments import ModelA... | 4,822 | 35.816794 | 116 | py |
tevatron | tevatron-main/src/tevatron/loss.py | import torch
from torch import Tensor
from torch.nn import functional as F
from torch import distributed as dist
class SimpleContrastiveLoss:
def __call__(self, x: Tensor, y: Tensor, target: Tensor = None, reduction: str = 'mean'):
if target is None:
target_per_qry = y.size(0) // x.size(0)
... | 1,438 | 36.868421 | 97 | py |
tevatron | tevatron-main/src/tevatron/data.py | import random
from dataclasses import dataclass
from typing import List, Tuple
import datasets
from torch.utils.data import Dataset
from transformers import PreTrainedTokenizer, BatchEncoding, DataCollatorWithPadding
from .arguments import DataArguments
from .trainer import TevatronTrainer
import logging
logger = l... | 4,665 | 30.315436 | 97 | py |
tevatron | tevatron-main/src/tevatron/trainer.py | import os
from itertools import repeat
from typing import Dict, List, Tuple, Optional, Any, Union
from transformers.trainer import Trainer
import torch
from torch.utils.data import DataLoader
import torch.distributed as dist
from .loss import SimpleContrastiveLoss, DistributedContrastiveLoss
import logging
logger =... | 4,040 | 33.245763 | 111 | py |
tevatron | tevatron-main/src/tevatron/driver/jax_train.py | import logging
import os
import sys
from functools import partial
import datasets
import jax
import jax.numpy as jnp
import optax
from flax import jax_utils, traverse_util
from flax.jax_utils import prefetch_to_device
from flax.training.common_utils import get_metrics, shard
from torch.utils.data import DataLoader, It... | 11,889 | 39.03367 | 133 | py |
tevatron | tevatron-main/src/tevatron/driver/jax_encode.py | import logging
import os
import pickle
import sys
import datasets
import jax
import numpy as np
from flax.training.common_utils import shard
from jax import pmap
from tevatron.arguments import DataArguments
from tevatron.arguments import TevatronTrainingArguments as TrainingArguments
from tevatron.arguments import Mod... | 4,719 | 38.663866 | 116 | py |
tevatron | tevatron-main/src/tevatron/driver/encode.py | import logging
import os
import pickle
import sys
from contextlib import nullcontext
import numpy as np
from tqdm import tqdm
import torch
from torch.utils.data import DataLoader
from transformers import AutoConfig, AutoTokenizer
from transformers import (
HfArgumentParser,
)
from tevatron.arguments import Mode... | 4,069 | 35.339286 | 116 | py |
tevatron | tevatron-main/src/tevatron/driver/train.py | import logging
import os
import sys
import torch
from transformers import AutoConfig, AutoTokenizer
from transformers import (
HfArgumentParser,
set_seed,
)
from tevatron.arguments import ModelArguments, DataArguments, \
TevatronTrainingArguments as TrainingArguments
from tevatron.data import TrainDataset... | 3,743 | 33.036364 | 133 | py |
tevatron | tevatron-main/src/tevatron/reranker/modeling.py | import os
from dataclasses import dataclass
from typing import Dict, Optional
import torch
from torch import nn, Tensor
from transformers import AutoModelForSequenceClassification, PreTrainedModel
from transformers.file_utils import ModelOutput
from tevatron.arguments import ModelArguments, \
TevatronTrainingArgu... | 2,994 | 34.235294 | 102 | py |
tevatron | tevatron-main/src/tevatron/reranker/data.py | from cgitb import text
import random
from dataclasses import dataclass
from typing import List, Tuple
import datasets
from torch.utils.data import Dataset
from transformers import PreTrainedTokenizer, BatchEncoding, DataCollatorWithPadding
from tevatron.arguments import DataArguments
import logging
logger = logging... | 6,235 | 36.119048 | 119 | py |
tevatron | tevatron-main/src/tevatron/utils/convert_from_dpr.py | import os
import torch
import argparse
from transformers import AutoConfig, AutoTokenizer
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--dpr_model', required=True)
parser.add_argument('--save_to', required=True)
args = parser.parse_args()
dpr_model_ckpt = torch.load(args.dp... | 1,360 | 40.242424 | 99 | py |
tevatron | tevatron-main/src/tevatron/modeling/dense.py | import torch
import torch.nn as nn
from torch import Tensor
import logging
from .encoder import EncoderPooler, EncoderModel
logger = logging.getLogger(__name__)
class DensePooler(EncoderPooler):
def __init__(self, input_dim: int = 768, output_dim: int = 768, tied=True, normalize=False):
super(DensePooler... | 2,361 | 30.493333 | 111 | py |
tevatron | tevatron-main/src/tevatron/modeling/encoder.py | import copy
import json
import os
from dataclasses import dataclass
from typing import Dict, Optional
import torch
from torch import nn, Tensor
import torch.distributed as dist
from transformers import PreTrainedModel, AutoModel
from transformers.file_utils import ModelOutput
from tevatron.arguments import ModelArgum... | 9,210 | 34.840467 | 112 | py |
tevatron | tevatron-main/src/tevatron/modeling/splade.py | import torch
import logging
from transformers import AutoModelForMaskedLM
from .encoder import EncoderModel
logger = logging.getLogger(__name__)
class SpladeModel(EncoderModel):
TRANSFORMER_CLS = AutoModelForMaskedLM
def encode_passage(self, psg):
if psg is None:
return None
psg_... | 824 | 32 | 122 | py |
tevatron | tevatron-main/src/tevatron/modeling/colbert.py | import torch
import torch.nn as nn
from torch import Tensor
import logging
from .encoder import EncoderPooler, EncoderModel
logger = logging.getLogger(__name__)
class ColbertPooler(EncoderPooler):
def __init__(self, input_dim: int = 768, output_dim: int = 32, tied=True):
super(ColbertPooler, self).__init... | 2,172 | 30.492754 | 87 | py |
tevatron | tevatron-main/src/tevatron/modeling/unicoil.py | import torch
from torch import Tensor, nn
import logging
from .encoder import EncoderPooler, EncoderModel
logger = logging.getLogger(__name__)
class UniCoilPooler(EncoderPooler):
def __init__(self, input_dim: int = 768, tied=True):
super(UniCoilPooler, self).__init__()
self.linear_q = nn.Linear(... | 2,537 | 33.297297 | 116 | py |
tevatron | tevatron-main/src/tevatron/distillation/data.py | import random
from dataclasses import dataclass
from typing import List, Tuple
import datasets
from datasets import load_dataset
from torch.utils.data import Dataset
from transformers import DataCollatorWithPadding, PreTrainedTokenizer, BatchEncoding
from transformers.tokenization_utils_base import PreTrainedTokenizer... | 9,166 | 42.445498 | 130 | py |
tevatron | tevatron-main/src/tevatron/distillation/trainer.py | import os
from typing import Dict, List, Tuple, Optional, Any, Union
from transformers.trainer import Trainer
import torch
from torch.utils.data import DataLoader
import torch.distributed as dist
from torch import nn
import logging
logger = logging.getLogger(__name__)
class DistilTrainer(Trainer):
def __init__... | 3,595 | 39.404494 | 147 | py |
tevatron | tevatron-main/src/tevatron/tevax/loss.py | import jax.numpy as jnp
from jax import lax
import optax
import chex
def _onehot(labels: chex.Array, num_classes: int) -> chex.Array:
x = labels[..., None] == jnp.arange(num_classes).reshape((1,) * labels.ndim + (-1,))
x = lax.select(x, jnp.ones(x.shape), jnp.zeros(x.shape))
return x.astype(jnp.float32)
... | 804 | 35.590909 | 108 | py |
tevatron | tevatron-main/src/tevatron/tevax/training.py | from functools import partial
from typing import Tuple, Any, Union
import jax
from jax import numpy as jnp
from flax.training.train_state import TrainState
from flax.core import FrozenDict
from flax.struct import PyTreeNode
from .loss import p_contrastive_loss
class TiedParams(PyTreeNode):
params: FrozenDict[s... | 3,485 | 32.84466 | 118 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/sequence_generator.py | """
Modified from
https://github.com/facebookresearch/fairseq/blob/main/fairseq/sequence_generator.py
"""
import math
from typing import Dict, List, Optional
import sys
import torch
import torch.nn as nn
from fairseq import search, utils
from fairseq.data import data_utils
from fairseq.models import Fairseq... | 39,854 | 38.855 | 149 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/modules/multihead_attention.py | # --------------------------------------------------------
# Pre-Training Transformer Decoder for End-to-End ASR Model with Unpaired Speech Data (https://arxiv.org/abs/2203.17113)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/Speech2C
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [s... | 13,608 | 38.792398 | 120 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/modules/relative_pos_enc.py | # --------------------------------------------------------
# Pre-Training Transformer Decoder for End-to-End ASR Model with Unpaired Speech Data (https://arxiv.org/abs/2203.17113)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/Speech2C
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [s... | 1,328 | 35.916667 | 120 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/modules/transformer_decoder.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 19,795 | 36.778626 | 133 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/modules/multimodal_transformer_decoder.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 20,517 | 38.007605 | 133 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/modules/w2v_encoder.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 10,046 | 34.376761 | 120 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/modules/transformer_decoder_layer.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 9,151 | 40.6 | 120 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/criterions/ctc_ce.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 16,716 | 39.281928 | 127 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/criterions/joint_step1_split_batch_criterion.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 16,793 | 44.266846 | 134 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/criterions/joint_step2_criterion.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 18,464 | 42.447059 | 134 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/criterions/joint_step1_criterion.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 16,028 | 42.675749 | 134 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/models/_hubert_mt.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 contextlib
from argparse import Namespace
from typing import Any, Optional
import torch
import torch.nn as nn
from data... | 12,264 | 38.437299 | 110 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/models/pretrain_ed_step2.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 17,979 | 39.95672 | 155 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/models/finetune_st.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 19,688 | 44.262069 | 195 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/models/pretrain_ed.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 28,635 | 39.967096 | 148 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/models/finetune_mt.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 14,237 | 38.994382 | 120 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/models/finetune_asr.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 20,151 | 42.713666 | 191 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/data/speech2c_dataset.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 8,595 | 37.547085 | 218 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/data/concat_dataset.py | # modalified from https://github.com/facebookresearch/fairseq/blob/main/fairseq/data/concat_dataset.py
import bisect
import numpy as np
from torch.utils.data.dataloader import default_collate
from fairseq.data import FairseqDataset
class ConcatDataset(FairseqDataset):
@staticmethod
def cumsum(sequence, sam... | 4,756 | 37.056 | 102 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/data/lang_pair_mask_dataset.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 2,076 | 31.968254 | 120 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/data/denoising_dataset.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 2,796 | 29.736264 | 120 | py |
SpeechT5 | SpeechT5-main/YiTrans/yitrans_iwslt22/tasks/iwslt_translation_from_pretrain.py | # --------------------------------------------------------
# The YiTrans End-to-End Speech Translation System for IWSLT 2022 Offline Shared Task (https://arxiv.org/abs/2206.05777)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/YiTrans
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [se... | 9,509 | 36.588933 | 137 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/modules/learned_positional_embedding.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
"""
Modified from https://githu... | 2,655 | 36.942857 | 119 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/modules/multihead_attention.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
from typing import Dict, Optional, ... | 13,731 | 38.573487 | 115 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/modules/relative_pos_enc.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
import torch
class RelativePositio... | 1,142 | 32.617647 | 61 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/modules/transformer_decoder.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
"""
Modified from https://githu... | 20,289 | 36.297794 | 133 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/modules/w2v_encoder.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
"""
wav2vec encoder adding reli... | 9,801 | 33.758865 | 114 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/modules/transformer_encoder.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
import math
from typing import Dict... | 15,939 | 38.651741 | 154 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/modules/transformer_layer.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
"""
Modified from https://githu... | 13,447 | 39.628399 | 137 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/criterions/speechut_criterion.py | # ----------------------------------------------------------------------------
# SpeechUT: Bridging Speech and Text with Hidden-Unit for Encoder-Decoder Based Speech-Text Pre-training (https://arxiv.org/abs/2210.03730)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/SpeechUT
# Code based on fairseq: ht... | 16,798 | 42.633766 | 165 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/criterions/ctc_ce.py | # ----------------------------------------------------------------------------
# SpeechUT: Bridging Speech and Text with Hidden-Unit for Encoder-Decoder Based Speech-Text Pre-training (https://arxiv.org/abs/2210.03730)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/SpeechUT
# Code based on fairseq: ht... | 16,818 | 39.527711 | 139 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/models/t5_transformer_lm.py | # --------------------------------------------------------
# Pre-Training Transformer Decoder for End-to-End ASR Model with Unpaired Speech Data (https://arxiv.org/abs/2203.17113)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/Speech2C
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [s... | 1,221 | 46 | 120 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/models/speechut_st.py | # ----------------------------------------------------------------------------
# SpeechUT: Bridging Speech and Text with Hidden-Unit for Encoder-Decoder Based Speech-Text Pre-training (https://arxiv.org/abs/2210.03730)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/SpeechUT
# Code based on fairseq: ht... | 8,484 | 37.220721 | 139 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/models/speechut_asr.py | # ----------------------------------------------------------------------------
# SpeechUT: Bridging Speech and Text with Hidden-Unit for Encoder-Decoder Based Speech-Text Pre-training (https://arxiv.org/abs/2210.03730)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/SpeechUT
# Code based on fairseq: ht... | 6,148 | 36.042169 | 139 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/models/speechut.py | # ----------------------------------------------------------------------------
# SpeechUT: Bridging Speech and Text with Hidden-Unit for Encoder-Decoder Based Speech-Text Pre-training (https://arxiv.org/abs/2210.03730)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/SpeechUT
# Code based on fairseq: ht... | 30,137 | 37.343511 | 156 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/stpretrain_scripts/data_process/merge_code.py | import sys
import torch
def main():
for line in sys.stdin:
line = line.rstrip()
codes = list(map(int, line.split()))
merged_codes = torch.unique_consecutive(torch.tensor(codes)).numpy()
merged_codes = map(str, merged_codes)
print(" ".join(merged_codes))
if __name__ == "__m... | 339 | 21.666667 | 76 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/scripts/average_checkpoints.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import collections
import os
import re
import torch
from fairseq.file_io import PathManager
def aver... | 6,075 | 36.73913 | 126 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/data/hubert_dataset.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
import itertools
import logging
imp... | 23,530 | 38.349498 | 218 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/data/concat_dataset.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
import bisect
import numpy as np
f... | 4,937 | 36.984615 | 86 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/data/language_trible_dataset.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
import logging
import numpy as np
i... | 25,659 | 37.298507 | 115 | py |
SpeechT5 | SpeechT5-main/Speech2S/speech2s/tasks/joint_sc2t_pretrain.py | # ----------------------------------------------------------------------------
# SpeechUT: Bridging Speech and Text with Hidden-Unit for Encoder-Decoder Based Speech-Text Pre-training (https://arxiv.org/abs/2210.03730)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/SpeechUT
# Code based on fairseq: ht... | 40,295 | 39.095522 | 156 | py |
SpeechT5 | SpeechT5-main/SpeechUT/speechut/squence_generator.py | # ----------------------------------------------------------------------------
# SpeechUT: Bridging Speech and Text with Hidden-Unit for Encoder-Decoder Based Speech-Text Pre-training (https://arxiv.org/abs/2210.03730)
# Github source: https://github.com/microsoft/SpeechT5/tree/main/SpeechUT
# Code based on fairseq: ht... | 46,747 | 40.776586 | 149 | py |
SpeechT5 | SpeechT5-main/SpeechUT/speechut/modules/learned_positional_embedding.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
"""
Modified from https://githu... | 2,655 | 36.942857 | 119 | py |
SpeechT5 | SpeechT5-main/SpeechUT/speechut/modules/multihead_attention.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
from typing import Dict, Optional, ... | 13,731 | 38.573487 | 115 | py |
SpeechT5 | SpeechT5-main/SpeechUT/speechut/modules/relative_pos_enc.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
import torch
class RelativePositio... | 1,142 | 32.617647 | 61 | py |
SpeechT5 | SpeechT5-main/SpeechUT/speechut/modules/transformer_decoder.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
"""
Modified from https://githu... | 20,289 | 36.297794 | 133 | py |
SpeechT5 | SpeechT5-main/SpeechUT/speechut/modules/w2v_encoder.py | # --------------------------------------------------------
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on fairseq code bases
# https://github.com/facebookresearch/fairseq
# --------------------------------------------------------
"""
wav2vec encoder adding reli... | 9,801 | 33.758865 | 114 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.