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 |
|---|---|---|---|---|---|---|
alibi-detect | alibi-detect-master/doc/source/conf.py | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... | 11,119 | 31.138728 | 139 | py |
InfoGAN | InfoGAN-master/launchers/run_mnist_exp.py | from __future__ import print_function
from __future__ import absolute_import
from infogan.misc.distributions import Uniform, Categorical, Gaussian, MeanBernoulli
import tensorflow as tf
import os
from infogan.misc.datasets import MnistDataset
from infogan.models.regularized_gan import RegularizedGAN
from infogan.algos... | 1,758 | 25.651515 | 84 | py |
InfoGAN | InfoGAN-master/launchers/__init__.py | from __future__ import print_function
from __future__ import absolute_import | 76 | 37.5 | 38 | py |
InfoGAN | InfoGAN-master/tests/test_distributions.py | from __future__ import print_function
from __future__ import absolute_import
from nose2.tools import such
from misc.distributions import Categorical, Gaussian, Product, Bernoulli
import numpy as np
import tensorflow as tf
sess = tf.Session()
def random_softmax(ndim):
x = np.random.uniform(size=(ndim,))
x = ... | 5,105 | 34.957746 | 119 | py |
InfoGAN | InfoGAN-master/tests/__init__.py | from __future__ import print_function
from __future__ import absolute_import | 76 | 37.5 | 38 | py |
InfoGAN | InfoGAN-master/infogan/__init__.py | from __future__ import print_function
from __future__ import absolute_import | 76 | 37.5 | 38 | py |
InfoGAN | InfoGAN-master/infogan/models/regularized_gan.py | from infogan.misc.distributions import Product, Distribution, Gaussian, Categorical, Bernoulli
import prettytensor as pt
import tensorflow as tf
import infogan.misc.custom_ops
from infogan.misc.custom_ops import leaky_rectify
class RegularizedGAN(object):
def __init__(self, output_dist, latent_spec, batch_size, i... | 7,290 | 42.921687 | 127 | py |
InfoGAN | InfoGAN-master/infogan/models/__init__.py | from __future__ import print_function
from __future__ import absolute_import | 76 | 37.5 | 38 | py |
InfoGAN | InfoGAN-master/infogan/algos/infogan_trainer.py | from infogan.models.regularized_gan import RegularizedGAN
import prettytensor as pt
import tensorflow as tf
import numpy as np
from progressbar import ETA, Bar, Percentage, ProgressBar
from infogan.misc.distributions import Bernoulli, Gaussian, Categorical
import sys
TINY = 1e-8
class InfoGANTrainer(object):
def... | 11,833 | 44.515385 | 118 | py |
InfoGAN | InfoGAN-master/infogan/algos/__init__.py | from __future__ import print_function
from __future__ import absolute_import | 76 | 37.5 | 38 | py |
InfoGAN | InfoGAN-master/infogan/misc/custom_ops.py | import prettytensor as pt
import tensorflow as tf
from prettytensor.pretty_tensor_class import Phase
import numpy as np
class conv_batch_norm(pt.VarStoreMethod):
"""Code modification of http://stackoverflow.com/a/33950177"""
def __call__(self, input_layer, epsilon=1e-5, momentum=0.1, name="batch_norm",
... | 5,501 | 44.098361 | 120 | py |
InfoGAN | InfoGAN-master/infogan/misc/distributions.py | from __future__ import print_function
from __future__ import absolute_import
import itertools
import tensorflow as tf
import numpy as np
TINY = 1e-8
floatX = np.float32
class Distribution(object):
@property
def dist_flat_dim(self):
"""
:rtype: int
"""
raise NotImplementedErro... | 14,122 | 28.795359 | 117 | py |
InfoGAN | InfoGAN-master/infogan/misc/utils.py | from __future__ import print_function
from __future__ import absolute_import
import errno
import os
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
| 309 | 19.666667 | 61 | py |
InfoGAN | InfoGAN-master/infogan/misc/datasets.py | import numpy as np
from tensorflow.examples.tutorials import mnist
import os
import numpy as np
class Dataset(object):
def __init__(self, images, labels=None):
self._images = images.reshape(images.shape[0], -1)
self._labels = labels
self._epochs_completed = -1
self._num_examples = ... | 2,749 | 30.25 | 71 | py |
InfoGAN | InfoGAN-master/infogan/misc/__init__.py | from __future__ import print_function
from __future__ import absolute_import | 76 | 37.5 | 38 | py |
StarGANv2-VC | StarGANv2-VC-main/losses.py | #coding:utf-8
import os
import torch
from torch import nn
from munch import Munch
from transforms import build_transforms
import torch.nn.functional as F
import numpy as np
def compute_d_loss(nets, args, x_real, y_org, y_trg, z_trg=None, x_ref=None, use_r1_reg=True, use_adv_cls=False, use_con_reg=False):
args =... | 7,608 | 34.390698 | 132 | py |
StarGANv2-VC | StarGANv2-VC-main/optimizers.py | #coding:utf-8
import os, sys
import os.path as osp
import numpy as np
import torch
from torch import nn
from torch.optim import Optimizer
from functools import reduce
from torch.optim import AdamW
class MultiOptimizer:
def __init__(self, optimizers={}, schedulers={}):
self.optimizers = optimizers
s... | 2,460 | 32.256757 | 103 | py |
StarGANv2-VC | StarGANv2-VC-main/meldataset.py | #coding: utf-8
import os
import time
import random
import random
import torch
import torchaudio
import numpy as np
import soundfile as sf
import torch.nn.functional as F
from torch import nn
from torch.utils.data import DataLoader
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
n... | 5,161 | 32.089744 | 100 | py |
StarGANv2-VC | StarGANv2-VC-main/models.py | """
StarGAN v2
Copyright (c) 2020-present NAVER Corp.
This work is licensed under the Creative Commons Attribution-NonCommercial
4.0 International License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
Creative Commons, PO Box 1866, Mountain View, CA 94042, USA... | 13,766 | 34.3 | 124 | py |
StarGANv2-VC | StarGANv2-VC-main/train.py | #!/usr/bin/env python3
#coding:utf-8
import os
import os.path as osp
import re
import sys
import yaml
import shutil
import numpy as np
import torch
import click
import warnings
warnings.simplefilter('ignore')
from functools import reduce
from munch import Munch
from meldataset import build_dataloader
from optimizers... | 5,523 | 34.184713 | 90 | py |
StarGANv2-VC | StarGANv2-VC-main/trainer.py | # -*- coding: utf-8 -*-
import os
import os.path as osp
import sys
import time
from collections import defaultdict
import numpy as np
import torch
from torch import nn
from PIL import Image
from tqdm import tqdm
from losses import compute_d_loss, compute_g_loss
import logging
logger = logging.getLogger(__name__)
lo... | 11,715 | 40.399293 | 175 | py |
StarGANv2-VC | StarGANv2-VC-main/transforms.py | # -*- coding: utf-8 -*-
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
import torchaudio
import torchaudio.functional as audio_F
import random
## 1. RandomTimeStrech
class TimeStrech(nn.Module):
def __init__(self, scale):
super(TimeStrech, self).__init__()
se... | 3,552 | 28.363636 | 106 | py |
StarGANv2-VC | StarGANv2-VC-main/Utils/__init__.py | 1 | 0 | 0 | py | |
StarGANv2-VC | StarGANv2-VC-main/Utils/JDC/model.py | """
Implementation of model from:
Kum et al. - "Joint Detection and Classification of Singing Voice Melody Using
Convolutional Recurrent Neural Networks" (2019)
Link: https://www.semanticscholar.org/paper/Joint-Detection-and-Classification-of-Singing-Voice-Kum-Nam/60a2ad4c7db43bace75805054603747fcd062c0d
"""
import tor... | 7,157 | 39.670455 | 144 | py |
StarGANv2-VC | StarGANv2-VC-main/Utils/JDC/__init__.py | 1 | 0 | 0 | py | |
StarGANv2-VC | StarGANv2-VC-main/Utils/ASR/layers.py | import math
import torch
from torch import nn
from typing import Optional, Any
from torch import Tensor
import torch.nn.functional as F
import torchaudio
import torchaudio.functional as audio_F
import random
random.seed(0)
def _get_activation_fn(activ):
if activ == 'relu':
return nn.ReLU()
elif activ... | 13,454 | 36.901408 | 143 | py |
StarGANv2-VC | StarGANv2-VC-main/Utils/ASR/models.py | import math
import torch
from torch import nn
from torch.nn import TransformerEncoder
import torch.nn.functional as F
from .layers import MFCC, Attention, LinearNorm, ConvNorm, ConvBlock
class ASRCNN(nn.Module):
def __init__(self,
input_dim=80,
hidden_dim=256,
n_t... | 7,272 | 37.893048 | 118 | py |
StarGANv2-VC | StarGANv2-VC-main/Utils/ASR/__init__.py | 1 | 0 | 0 | py | |
Signal-is-Harder | Signal-is-Harder-main/train_vanilla.py | import os
import yaml
import argparse
import wandb
import time
from tqdm import tqdm
import torch
from torch.utils.data import DataLoader
import torch.optim as optim
from data.util import get_dataset, IdxDataset
from module.util import get_model
from util import set_seed, get_optimizer, evaluate
def main():
... | 7,018 | 32.42381 | 249 | py |
Signal-is-Harder | Signal-is-Harder-main/make_dataset.py | '''Modified from https://github.com/alinlab/LfF/blob/master/util.py'''
import os
from re import A
from xmlrpc.client import Boolean
from tqdm import tqdm
import pickle
import numpy as np
import torch
from torchvision.datasets import CIFAR10, MNIST
import torchvision.transforms as T
from data.corrupted_cifar10_protoc... | 41,294 | 46.194286 | 133 | py |
Signal-is-Harder | Signal-is-Harder-main/util.py | import os
import random
import numpy as np
import torch
from tqdm import tqdm
import torch.nn as nn
import torch.nn.functional as F
import wandb
from torchvision.transforms.functional import normalize
def set_seed(seed):
"""
Set all random seeds
Args:
seed (int): integer for reproducible experim... | 28,920 | 45.646774 | 229 | py |
Signal-is-Harder | Signal-is-Harder-main/train.py | import os
import yaml
import argparse
import wandb
import time
import sys
from tqdm import tqdm
import numpy as np
from uuid import uuid4
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import DataLoader
from torchvision.transforms.functional import ... | 18,917 | 48.010363 | 285 | py |
Signal-is-Harder | Signal-is-Harder-main/module/resnet_vae.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from torchvision.models import resnet18
from module.resnet import resnet20
class ResNet_VAE(nn.Module):
def __init__(self, num_classes = 10, bottleneck=512):
super(ResNet_VAE, self).__init__()
self.enco... | 5,542 | 33.216049 | 119 | py |
Signal-is-Harder | Signal-is-Harder-main/module/mlp_vae.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class MLP_VAE(nn.Module):
def __init__(self, num_classes = 10, bottleneck = 16):
super(MLP_VAE, self).__init__()
self.encoder = MLP_Encoder(bottleneck = bottleneck)
self.decoder = MLP_Decoder(bottleneck = bottleneck)
... | 2,499 | 25.041667 | 96 | py |
Signal-is-Harder | Signal-is-Harder-main/module/resnet.py | ''' From https://github.com/alinlab/LfF/blob/master/module/resnet.py '''
"""
Properly implemented ResNet-s for CIFAR10 as described in paper [1].
The implementation and structure of this file is hugely influenced by [2]
which is implemented for ImageNet and doesn't have option A for identity.
Moreover, most of the imp... | 6,138 | 27.290323 | 78 | py |
Signal-is-Harder | Signal-is-Harder-main/module/mlp.py | ''' From https://github.com/alinlab/LfF/blob/master/module/MLP.py '''
import torch
import torch.nn as nn
class MLP(nn.Module):
def __init__(self, num_classes = 10):
super(MLP, self).__init__()
self.feature = nn.Sequential(
nn.Linear(3 * 28*28, 100),
nn.ReLU(),
n... | 721 | 25.740741 | 69 | py |
Signal-is-Harder | Signal-is-Harder-main/module/util.py | ''' Modified from https://github.com/alinlab/LfF/blob/master/module/util.py '''
import torch.nn as nn
from module.resnet import resnet20
from module.mlp import MLP
from module.mlp_vae import MLP_VAE
from module.resnet_vae import ResNet_VAE
from torchvision.models import resnet18, resnet50
def get_model(config):
m... | 2,150 | 36.736842 | 100 | py |
Signal-is-Harder | Signal-is-Harder-main/data/rotated_mnist_protocol.py | import os
from functools import partial
import torchvision.transforms.functional as F
dir_path = os.path.dirname(os.path.realpath(__file__))
def rotate(raw_image, severity, attribute_label):
if severity==0:
raise NotImplementedError("Need severity != 0")
rotation = 90/(5-severity)
if attribute_lab... | 662 | 32.15 | 76 | py |
Signal-is-Harder | Signal-is-Harder-main/data/attr_dataset.py | '''Modified from https://github.com/alinlab/LfF/blob/master/data/attr_dataset.py'''
import os
import pickle
import torch
import numpy as np
from torch.utils.data import Dataset
class AttributeDataset(Dataset):
def __init__(self, root, split, query_attr_idx=None, transform=None):
super(AttributeDataset, s... | 1,335 | 31.585366 | 83 | py |
Signal-is-Harder | Signal-is-Harder-main/data/shifted_mnist_protocol.py | import os
from functools import partial
import torchvision.transforms.functional as F
dir_path = os.path.dirname(os.path.realpath(__file__))
def shift(raw_image, severity, attribute_label):
if severity==0:
raise NotImplementedError("Need severity != 0")
translation = 8/(5-severity)
if attribute_la... | 845 | 35.782609 | 131 | py |
Signal-is-Harder | Signal-is-Harder-main/data/corrupted_cifar10_protocol.py | '''Modified from https://github.com/alinlab/LfF/blob/master/data/corrupted_cifar10_protocol.py'''
# -*- coding: utf-8 -*-
import os
from PIL import Image
import os.path
import time
import numpy as np
from PIL import Image
# /////////////// Distortion Helpers ///////////////
import skimage as sk
from skimage.filt... | 16,647 | 28.942446 | 97 | py |
Signal-is-Harder | Signal-is-Harder-main/data/util.py | '''Modified from https://github.com/alinlab/LfF/blob/master/data/util.py'''
import os
import numpy as np
import torch
from torch.utils.data.dataset import Dataset, Subset
from torch.utils.data import Sampler, random_split
from torchvision import transforms as T
from data.attr_dataset import AttributeDataset
from func... | 4,488 | 29.746575 | 109 | py |
Signal-is-Harder | Signal-is-Harder-main/data/colored_mnist_protocol.py | '''Modified from https://github.com/alinlab/LfF/blob/master/data/colored_mnist_protocol.py'''
import os
import torch
import numpy as np
from functools import partial
dir_path = os.path.dirname(os.path.realpath(__file__))
colors_path = os.path.join(dir_path, "resource", "colors.th")
mean_color = torch.load(colors_path... | 742 | 31.304348 | 93 | py |
NNRec | NNRec-master/nn/__init__.py | 0 | 0 | 0 | py | |
NNRec | NNRec-master/nn/blocks/networkConfigParser.py | import yaml
from nn import *
from activations import *
from exceptions import Exception
from utils import *
# from cfRBM import ModelArgs
class NetworkConfigParser(object):
@classmethod
def getDataInfo(cls, path):
with open(path) as fp:
data = yaml.load(fp)
data_info = data["d... | 4,429 | 30.41844 | 73 | py |
NNRec | NNRec-master/nn/blocks/nn.py | import numpy as np
from copy import deepcopy
class LayerType(object):
INPUT = 0
HIDDEN = 1
OUTPUT = 2
class Layer:
def __init__(self, num_units, activation, layerType,
dropout=None, sparsity=None, partial=False, isBiasEnabled=True):
self.num_units = num_units
self.a... | 3,494 | 26.519685 | 82 | py |
NNRec | NNRec-master/nn/blocks/activations.py | import numpy as np
from cython_activations import *
class Activation(object):
"""docstring for Activation"""
def activation(self, x):
pass
def derivative(self, x):
pass
def binarize(self, x):
return x
class Identity(Activation):
"""docstring for Identity"""
def ... | 1,496 | 16.406977 | 69 | py |
NNRec | NNRec-master/nn/blocks/__init__.py | 0 | 0 | 0 | py | |
NNRec | NNRec-master/nn/blocks/setup_activations.py | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np
ext_module = Extension(
"cython_activations",
["cython_activations.pyx"],
extra_compile_args=['-fopenmp'],
extra_link_args=['-fopenmp'],
include_dirs=[np.get_include(... | 470 | 22.55 | 41 | py |
NNRec | NNRec-master/nn/cfrbm/cfRBM.py | import numpy as np
from cython_rbm_matmul import cython_binarizeSparseMatrix, multiplyOuterSparseLayer
from utils.metrics.evaluate import EvaluateRBM
class ModelArgs(object):
"""docstring for ModelArgs"""
def __init__(self, learn_rate=0.001, regularize_bias=True,
momentum=0.6, lamda=0.001, ... | 9,604 | 36.084942 | 83 | py |
NNRec | NNRec-master/nn/cfrbm/learner.py | from cfRBM import *
from dataUtils.data import loadTrainTest
# from nn.blocks.nn import Layer, NN, LayerType
from nn.blocks.activations import *
from nn.blocks.networkConfigParser import NetworkConfigParser
import yaml
def train(config_path):
configparser = NetworkConfigParser()
nn = configparser.constructNet... | 1,589 | 33.565217 | 76 | py |
NNRec | NNRec-master/nn/cfrbm/setup_rbm_matmul.py | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np
ext_module = Extension(
"cython_rbm_matmul",
["cython_rbm_matmul.pyx"],
extra_compile_args=['-fopenmp'],
extra_link_args=['-fopenmp'],
include_dirs=[np.get_include()]... | 465 | 22.3 | 41 | py |
NNRec | NNRec-master/nn/autorec/generateNNFeatures.py | import numpy as np
from nn.blocks.networkConfigParser import NetworkConfigParser
from modelLoader import loadModel, LoadDataAndMapping
def dumpArray(array, outpath, mapping):
fp = open(outpath, "wb")
m, n = array.shape
for i in range(m):
for j in range(n):
value = array[i, j]
... | 1,370 | 32.439024 | 71 | py |
NNRec | NNRec-master/nn/autorec/optimizers.py | import scipy.optimize
from climin import *
import itertools
# from sklearn.utils import shuffle
from lossDeriv import *
class LBFGS(object):
"""docstring for LBFGS"""
def __init__(self, ae, evaluate, theta, lossDeriv, train, test,
nn, modelArgs, iterCounter, batch_size, max_iter):
s... | 3,937 | 35.803738 | 79 | py |
NNRec | NNRec-master/nn/autorec/ae_utils.py | class Counter(object):
"""docstring for Counter"""
def __init__(self):
super(Counter, self).__init__()
self.count = 0
def increment(self):
self.count += 1
class ModelArgs(object):
"""docstring for ModelArgs"""
def __init__(self, learn_rate=0.001, lamda=1.0, regularize_... | 1,152 | 27.825 | 78 | py |
NNRec | NNRec-master/nn/autorec/learner.py | from utils.metrics.evaluate import EvaluateNN
from nn.blocks.networkConfigParser import NetworkConfigParser
from lossDeriv import *
from dataUtils.data import loadTrainTest
from ae import AE
from optimizers import getOptimizer
from ae_utils import Counter, ModelArgs
def train(config_path):
modelArgs = NetworkConf... | 2,029 | 33.40678 | 78 | py |
NNRec | NNRec-master/nn/autorec/ae.py | import numpy as np
import cPickle as pkl
from cython_matmul import *
from lossDeriv import *
from nn.blocks.activations import *
from nn.blocks.nn import *
class AE:
def __init__(self, nn, modelArgs, debug=True):
self.nn = nn
self.debug = debug
self.modelArgs = modelArgs
self.nn.s... | 3,899 | 37.613861 | 77 | py |
NNRec | NNRec-master/nn/autorec/lossDeriv.py | import numpy as np
import scipy.sparse
from nn.blocks.cython_activations import *
from cython_matmul import *
from nn.blocks.nn import LayerType
# from sklearn.utils import shuffle
from copy import deepcopy
EPS = 10e-15
def _getLossUpdateDerivative(batch_data, weights, biases,
dWeights,... | 19,732 | 38.152778 | 128 | py |
NNRec | NNRec-master/nn/autorec/__init__.py | 0 | 0 | 0 | py | |
NNRec | NNRec-master/nn/autorec/setup_matmul.py | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np
ext_module = Extension(
"cython_matmul",
["cython_matmul.pyx"],
extra_compile_args=['-fopenmp'],
extra_link_args=['-fopenmp'],
include_dirs=[np.get_include()]
)
se... | 459 | 22 | 41 | py |
NNRec | NNRec-master/nn/autorec/modelLoader.py | from ae import AE
import numpy as np
from nn.blocks.networkConfigParser import NetworkConfigParser
from dataUtils.data import Data, loadTestData
from utils.metrics.evaluate import EvaluateNN
from ae_utils import Counter, ModelArgs
def loadModel(config_path):
modelArgs = NetworkConfigParser.constructModelArgs(conf... | 2,433 | 32.342466 | 78 | py |
NNRec | NNRec-master/dataUtils/data.py | import envoy
import progressbar
import scipy.sparse
class Data(object):
def __init__(self):
self.users = {}
self.items = {}
self.nusers = 0
self.nitems = 0
self.include_time = False
def update_user_item(self, user, item):
if user not in self.users:
... | 3,977 | 36.17757 | 97 | py |
NNRec | NNRec-master/dataUtils/__init__.py | 0 | 0 | 0 | py | |
NNRec | NNRec-master/utils/statUtil.py | from scipy import stats
import math
def getConfidenceInterval(data, percent, distribution="t"):
n, min_max, mean, var, skew, kurt = stats.describe(data)
std = math.sqrt(var)
if distribution == "t":
R = stats.t.interval(
percent, len(data) - 1, loc=mean, scale=std / math.sqrt(len(data))... | 749 | 29 | 79 | py |
NNRec | NNRec-master/utils/__init__.py | 0 | 0 | 0 | py | |
NNRec | NNRec-master/utils/datetimeUtils.py | import ciso8601
import datetime
import envoy
from datetime import timedelta
def parseDateTime(datetimestring):
return ciso8601.parse_datetime(datetimestring)
def getDaysSinceX(inputdata, reference=None):
if reference is None:
reference = datetime.datetime.now()
input_time = parseDateTime(inputda... | 727 | 25 | 63 | py |
NNRec | NNRec-master/utils/metrics/evaluate.py |
from math import fabs, sqrt
import numpy as np
import scipy.sparse
class Evaluate(object):
"""docstring for Evaluate"""
def __init__(self, predictor):
super(Evaluate, self).__init__()
self.predictor = predictor
def calculateRMSEandMAE(self, test):
pass
class EvaluateConstant(... | 3,157 | 31.556701 | 87 | py |
NNRec | NNRec-master/utils/metrics/__init__.py | 0 | 0 | 0 | py | |
Multi2WOZ | Multi2WOZ-main/specialization/trainer_self.py | # coding=utf-8
# Copyright 2020-present the HuggingFace Inc. team.
#
# 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 ap... | 102,647 | 46.765472 | 146 | py |
Multi2WOZ | Multi2WOZ-main/specialization/opensubtitles.py | import json
import os
import random
import datasets
# _CITATION = """
# """
# _DESCRIPTION = """
# """
class OpensubtitlesConfig(datasets.BuilderConfig):
"""BuilderConfig for Opensubtitles."""
def __init__(
self,
language,
data_dir,
**kwargs,
):
"""BuilderConfig f... | 3,729 | 30.610169 | 98 | py |
Multi2WOZ | Multi2WOZ-main/specialization/run_mlm.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Team All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-... | 23,874 | 42.567518 | 128 | py |
Multi2WOZ | Multi2WOZ-main/specialization/run_rs.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Team All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-... | 22,061 | 41.426923 | 148 | py |
Multi2WOZ | Multi2WOZ-main/LangCC/langcc_extract.py | import os
import lzma
import re
import argparse
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--input_lang_file', type=str, help="input language file path") #"./de.txt.xz
parser.add_argument('--save_file_name', type=str, default = "./cc_de_500K.txt", help = "save file name for l... | 1,868 | 32.981818 | 126 | py |
Multi2WOZ | Multi2WOZ-main/LangCC/langcc_prep.py | import random
import numpy as np
from sklearn.model_selection import train_test_split
import argparse
import re
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--random_seed', type = int, default = 10, help="set random seed")
parser.add_argument('--train_size', type=int, default =... | 4,428 | 54.3625 | 245 | py |
Multi2WOZ | Multi2WOZ-main/LangOpenSubtitles/concat_files.py | import json
import argparse
import re, os
import random
import glob
import numpy as np
import linecache
import unicodedata
import pickle
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--file1', type=str, help='First file to process')
parser.add_argument('--file2', type=str, nargs... | 3,791 | 34.773585 | 167 | py |
Multi2WOZ | Multi2WOZ-main/LangOpenSubtitles/convert_mlm.py | import sys
import random
import argparse
from tqdm import *
import numpy as np
from sklearn.model_selection import train_test_split
import unicodedata
import json
import linecache
import pickle
# bi: 0
# mono: 1
random.seed(1)
np.random.seed(1)
def parse_args():
parser = argparse.ArgumentParser(description='Proce... | 20,237 | 38.527344 | 252 | py |
Multi2WOZ | Multi2WOZ-main/LangOpenSubtitles/extract_imdb_ids.py | import json
import argparse
import linecache
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--src_file', type = str, help="src language file")
parser.add_argument('--tgt_file', type = str, help="tgt language file")
parser.add_argument('--ids', type = str, help="ids file")
... | 1,452 | 34.439024 | 99 | py |
Multi2WOZ | Multi2WOZ-main/downstream/main_cl.py | from tqdm import tqdm
import torch.nn as nn
import ast
import glob
import numpy as np
import copy
# utils
from utils.config import *
from utils.utils_general import *
from utils.utils_multiwoz_cl import *
from utils.utils_oos_intent import *
from utils.utils_universal_act import *
# models
from models.BERT_DST_Pick... | 11,553 | 42.931559 | 114 | py |
Multi2WOZ | Multi2WOZ-main/downstream/tod_xlmr_pretraining.py | import argparse
import glob
import logging
import os
import pickle
import random
import re
import shutil
from typing import Tuple
import gzip
import shelve
import json
import math
import numpy as np
import torch
from torch.utils.data import DataLoader, Dataset, RandomSampler, SequentialSampler, TensorDataset
from torch... | 44,684 | 42.595122 | 141 | py |
Multi2WOZ | Multi2WOZ-main/downstream/main_cl-continue.py | from tqdm import tqdm
import torch.nn as nn
import ast
import glob
import numpy as np
import copy
# utils
from utils.config import *
from utils.utils_general import *
from utils.utils_multiwoz_cl import *
from utils.utils_oos_intent import *
from utils.utils_universal_act import *
# models
from models.BERT_DST_Pick... | 14,594 | 46.386364 | 159 | py |
Multi2WOZ | Multi2WOZ-main/downstream/models/dual_encoder_ranking.py | import os.path
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import optim
from torch.nn import CrossEntropyLoss
from torch.nn import CosineEmbeddingLoss
from sklearn.metrics import f1_score #, average_precision_score
import numpy as np
from transformers import *
import log... | 6,321 | 40.320261 | 132 | py |
Multi2WOZ | Multi2WOZ-main/downstream/models/BERT_DST_Picklist.py | import os.path
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import CrossEntropyLoss
from torch.nn import CosineEmbeddingLoss
import numpy as np
from transformers import *
def _gelu(x):
""" Original Implementation of the gelu activation function in Google Bert repo ... | 11,918 | 42.5 | 141 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_smd.py | import json
import ast
import collections
import os
from .utils_function import get_input_example
def read_langs_turn(args, file_name, max_line = None, ds_name=""):
print(("Reading from {} for read_langs_turn".format(file_name)))
data = []
with open(file_name) as f:
dials = json.load(f)... | 2,883 | 34.604938 | 98 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/dataloader_nlg.py | import torch
import torch.utils.data as data
import random
from .utils_function import to_cuda, merge
# from .config import *
class Dataset_nlg(torch.utils.data.Dataset):
"""Custom data.Dataset compatible with data.DataLoader."""
def __init__(self, data_info, tokenizer, args, unified_meta, mode, max_length=5... | 7,624 | 43.590643 | 115 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/dataloader_nlu.py | import torch
import torch.utils.data as data
# from .config import *
from .utils_function import to_cuda, merge, merge_multi_response, merge_sent_and_word
class Dataset_nlu(torch.utils.data.Dataset):
"""Custom data.Dataset compatible with data.DataLoader."""
def __init__(self, data_info, tokenizer, args, unifi... | 4,513 | 37.254237 | 115 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/dataloader_dm.py | import torch
import torch.utils.data as data
# from .config import *
from .utils_function import to_cuda, merge, merge_multi_response, merge_sent_and_word
class Dataset_dm(torch.utils.data.Dataset):
"""Custom data.Dataset compatible with data.DataLoader."""
def __init__(self, data_info, tokenizer, args, unifie... | 4,048 | 37.561905 | 137 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_multiwoz_cl.py | import json
import ast
import collections
import os
from .utils_function import get_input_example
from .multiwoz.fix_label import *
EXPERIMENT_DOMAINS = ["hotel", "train", "restaurant", "attraction", "taxi"] #, "hospital", "police"]
def read_langs_turn(args, file_name, ontology, dialog_act, max_line = None, domain_... | 13,939 | 50.821561 | 130 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_frames.py | import json
import ast
import collections
import os
from .utils_function import get_input_example
def read_langs_turn(args, file_name, max_line = None, ds_name=""):
print(("Reading from {} for read_langs_turn".format(file_name)))
data = []
with open(file_name) as f:
dials = json.load(f)... | 2,548 | 30.469136 | 98 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_metalwoz.py | import json
import ast
import collections
import os
from .utils_function import get_input_example
def read_langs_turn(args, dial_files, max_line = None, ds_name=""):
print(("Reading from {} for read_langs_turn".format(ds_name)))
data = []
cnt_lin = 1
for dial_file in dial_files:
... | 2,615 | 31.7 | 175 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_woz.py | import json
import ast
import collections
import os
from .utils_function import get_input_example
def read_langs_turn(args, file_name, max_line = None, ds_name=""):
print(("Reading from {} for read_langs_turn".format(file_name)))
data = []
with open(file_name) as f:
dials = json.load(f)... | 2,767 | 34.487179 | 101 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_multiwoz.py | import json
import ast
import collections
import os
from .utils_function import get_input_example
from .multiwoz.fix_label import *
EXPERIMENT_DOMAINS = ["hotel", "train", "restaurant", "attraction", "taxi"] #, "hospital", "police"]
def read_langs_turn(args, file_name, ontology, dialog_act, max_line = None, domain_... | 13,530 | 50.253788 | 130 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_taskmaster.py | import json
import ast
import collections
import os
from .utils_function import get_input_example
def read_langs_turn(args, dials, ds_name, max_line):
print(("Reading from {} for read_langs_turn".format(ds_name)))
data = []
turn_sys = ""
turn_usr = ""
cnt_lin = 1
for dial in dials:
... | 3,043 | 33.988506 | 107 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_msre2e.py | import json
import ast
import collections
import os
from .utils_function import get_input_example
def read_langs_turn(args, file_name, max_line = None, ds_name=""):
print(("Reading from {} for read_langs_turn".format(file_name)))
data = []
with open(file_name) as f:
dials = f.readlines(... | 3,276 | 33.135417 | 118 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_function.py | import torch
import numpy as np
PAD_token = 0
def to_cuda(x):
if torch.cuda.is_available(): x = x.cuda()
return x
def merge(sequences, ignore_idx=None):
'''
merge from batch * sent_len to batch * max_len
'''
pad_token = PAD_token if type(ignore_idx)==type(None) else ignore_idx
lengths =... | 3,659 | 28.28 | 82 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/config.py | import os
import logging
import argparse
from tqdm import tqdm
import torch
import numpy as np
parser = argparse.ArgumentParser(description='Task-oriented Dialogue System Benchmarking')
## Training Setting
parser.add_argument(
'--do_train', action='store_true', help="do training")
parser.add_argument(
'-ep... | 10,339 | 47.093023 | 150 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_schema.py | import json
import ast
import collections
import os
from .utils_function import get_input_example
def read_langs_turn(args, dial_files, max_line = None, ds_name=""):
print(("Reading from {} for read_langs_turn".format(ds_name)))
data = []
cnt_lin = 1
for dial_file in dial_files:
... | 3,333 | 38.690476 | 216 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/dataloader_dst.py | import torch
import numpy as np
import torch.utils.data as data
from .utils_function import to_cuda, merge, merge_multi_response, merge_sent_and_word
# SLOT_GATE = {"ptr":0, "dontcare":1, "none":2}
class Dataset_dst(torch.utils.data.Dataset):
"""Custom data.Dataset compatible with data.DataLoader."""
def __in... | 6,765 | 41.2875 | 137 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_general.py | import torch
import torch.utils.data as data
import random
import math
from .dataloader_dst import *
from .dataloader_nlg import *
from .dataloader_nlu import *
from .dataloader_dm import *
from .dataloader_usdl import *
def get_loader(args, mode, tokenizer, datasets, unified_meta, shuffle=False):
task = args["ta... | 3,348 | 39.349398 | 122 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/utils_oos_intent.py | import json
import ast
import os
import random
from .utils_function import get_input_example
def read_langs(args, dtype, _data, _oos_data):
print(("Reading [OOS Intent] for read_langs {}".format(dtype)))
data = []
intent_counter = {}
for cur_data in [_data, _oos_data]:
for d in cur_d... | 1,844 | 31.946429 | 92 | py |
Multi2WOZ | Multi2WOZ-main/downstream/utils/dataloader_usdl.py | import torch
import torch.utils.data as data
from .utils_function import to_cuda, merge, merge_multi_response, merge_sent_and_word
class Dataset_usdl(torch.utils.data.Dataset):
"""Custom data.Dataset compatible with data.DataLoader."""
def __init__(self, data_info, tokenizer, args, unified_meta, mode, max_leng... | 5,245 | 38.742424 | 118 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.