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
3SD
3SD-main/u2net_test.py
import os from skimage import io, transform import torch import torchvision from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F from torch.utils.data import Dataset, DataLoader from torchvision import transforms#, utils # import torch.optim as optim import numpy as np from PIL imp...
4,238
32.642857
129
py
3SD
3SD-main/smoothness/__init__.py
import torch import torch.nn.functional as F # from torch.autograd import Variable # import numpy as np def laplacian_edge(img): laplacian_filter = torch.Tensor([[-1, -1, -1], [-1, 8, -1], [-1, -1, -1]]) filter = torch.reshape(laplacian_filter, [1, 1, 3, 3]) filter = filter.cuda() lap_edge = F.conv2d(im...
2,014
30.484375
78
py
3SD
3SD-main/model/u2net.py
import torch import torch.nn as nn import torch.nn.functional as F class REBNCONV(nn.Module): def __init__(self,in_ch=3,out_ch=3,dirate=1): super(REBNCONV,self).__init__() self.conv_s1 = nn.Conv2d(in_ch,out_ch,3,padding=1*dirate,dilation=1*dirate) self.bn_s1 = nn.BatchNorm2d(out_ch) ...
14,719
26.984791
118
py
3SD
3SD-main/model/u2net_transformer_pseudo_dino_final.py
import torch import torch.nn as nn import torch.nn.functional as F # Copyright (c) Facebook, Inc. and its affiliates. # # 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.apach...
33,498
32.499
155
py
3SD
3SD-main/model/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # 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 ...
21,117
33.06129
115
py
3SD
3SD-main/model/u2net_refactor.py
import torch import torch.nn as nn import math __all__ = ['U2NET_full', 'U2NET_lite'] def _upsample_like(x, size): return nn.Upsample(size=size, mode='bilinear', align_corners=False)(x) def _size_map(x, height): # {height: size} for Upsample size = list(x.shape[-2:]) sizes = {} for h in range(...
6,097
35.08284
101
py
3SD
3SD-main/model/__init__.py
from .u2net_transformer_pseudo_dino_final import U2NET from .u2net import U2NETP
81
26.333333
54
py
3SD
3SD-main/model/u2net_transformer.py
import torch import torch.nn as nn import torch.nn.functional as F # Copyright (c) Facebook, Inc. and its affiliates. # # 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.apach...
30,678
31.917382
124
py
STFTgrad
STFTgrad-main/classifier/classifier_adaptive.py
""" Code for the adaptive classifier with the differentiable STFT front-end This will be trained on our test input signal, alternating sinusoids of 2 frequencies """ # Dependencies import numpy as np from tqdm import tqdm import haiku as hk import jax.numpy as jnp import jax import optax from dstft import diff_stft imp...
3,684
25.510791
120
py
STFTgrad
STFTgrad-main/classifier/classifier_ordinary.py
""" Code for a normal classifier (to obtain the loss function as a function of the window length) This will be trained on our test input signal, alternating sinusoids of 2 frequencies """ # Dependencies import numpy as np from tqdm import tqdm import haiku as hk import jax.numpy as jnp import jax import optax from dst...
3,916
25.828767
120
py
STFTgrad
STFTgrad-main/classifier/dstft.py
""" Code for the differentiable STFT front-end As explained in our paper, we use a Gaussian Window STFT, with N = floor(6\sigma) """ # Dependencies import jax.numpy as jnp import jax def diff_stft(xinp,s,hf = 0.5): """ Inputs ------ xinp: jnp.array Input audio signal in time domain s: jnp....
1,290
26.468085
154
py
STFTgrad
STFTgrad-main/adaptiveSTFT/adaptive_stft.py
import math from tqdm import trange import sys import pathlib import torch.autograd import torch import numpy as np import torch.optim import torch.nn as nn from celluloid import Camera import matplotlib.pyplot as plt from matplotlib.figure import Figure import torch.nn.functional as F from adaptive_stft_utils.operator...
11,853
39.875862
123
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/MNISTExperiment.py
from models import UMNNMAFFlow import torch from lib import dataloader as dl import lib as transform import lib.utils as utils import numpy as np import os import pickle from timeit import default_timer as timer import torchvision from tensorboardX import SummaryWriter writer = SummaryWriter() def train_mnist(datas...
13,329
49.492424
127
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/ToyExperiments.py
from models import UMNNMAFFlow import torch import lib.toy_data as toy_data import numpy as np import matplotlib.pyplot as plt from timeit import default_timer as timer import os import lib.utils as utils import lib.visualize_flow as vf green = '#e15647' black = '#2d5468' white_bg = '#ececec' def summary_plots(x, x_te...
7,250
37.775401
128
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/MonotonicMLP.py
import torch import argparse import torch.nn as nn import matplotlib.pyplot as plt from models.UMNN import MonotonicNN, IntegrandNN def f(x_1, x_2, x_3): return .001*(x_1**3 + x_1) + x_2 ** 2 + torch.sin(x_3) def create_dataset(n_samples): x = torch.randn(n_samples, 3) y = f(x[:, 0], x[:, 1], x[:, 2]) ...
3,487
35.715789
96
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/UCIExperiments.py
from models import UMNNMAFFlow import torch import numpy as np import os import pickle import lib.utils as utils import datasets from timeit import default_timer as timer from tensorboardX import SummaryWriter writer = SummaryWriter() def batch_iter(X, batch_size, shuffle=False): """ X: feature tensor (shape...
10,219
41.941176
131
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/TrainVaeFlow.py
# !/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import argparse import time import torch import torch.utils.data import torch.optim as optim import numpy as np import math import random import os import datetime import lib.utils as utils from models.vae_lib.models import VAE fro...
13,750
39.444118
124
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/setup.py
from setuptools import setup setup( name='UMNN', version='0.1', packages=['UMNN'], url='', license='MIT License', author='awehenkel', author_email='[email protected]', description='' )
227
16.538462
46
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/__init__.py
from .UMNN import UMNNMAFFlow, MADE, ParallelNeuralIntegral, NeuralIntegral
76
37.5
75
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/__init__.py
0
0
0
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/models/VAE.py
from __future__ import print_function import torch import torch.nn as nn from ...vae_lib.models import flows from ...vae_lib.models.layers import GatedConv2d, GatedConvTranspose2d class VAE(nn.Module): """ The base VAE class containing gated convolutional encoder and decoder architecture. Can be used as ...
26,921
32.949559
136
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/models/CNFVAE.py
import torch import torch.nn as nn from train_misc import build_model_tabular from UMNNMAF import lib as layers import lib as diffeq_layers from .VAE import VAE from lib import NONLINEARITIES from torchdiffeq import odeint_adjoint as odeint def get_hidden_dims(args): return tuple(map(int, args.dims.split("-"))) ...
14,375
33.808717
116
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/models/layers.py
import torch import torch.nn as nn from torch.nn.parameter import Parameter import numpy as np import torch.nn.functional as F class Identity(nn.Module): def __init__(self): super(Identity, self).__init__() def forward(self, x): return x class GatedConv2d(nn.Module): def __init__(self...
7,128
32.947619
115
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/models/__init__.py
0
0
0
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/models/flows.py
""" Collection of flow strategies """ from __future__ import print_function import numpy as np import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F from ...vae_lib.models.layers import MaskedConv2d, MaskedLinear import sys sys.path.append("../../") from models import...
10,990
32.306061
118
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/optimization/loss.py
from __future__ import print_function import numpy as np import torch import torch.nn as nn from ...vae_lib.utils.distributions import log_normal_diag, log_normal_standard, log_bernoulli import torch.nn.functional as F def binary_loss_function(recon_x, x, z_mu, z_var, z_0, z_k, ldj, beta=1.): """ Computes th...
10,621
38.051471
116
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/optimization/training.py
from __future__ import print_function import time import torch from ...vae_lib.optimization.loss import calculate_loss from ...vae_lib.utils.visual_evaluation import plot_reconstructions from ...vae_lib.utils.log_likelihood import calculate_likelihood import numpy as np def train(epoch, train_loader, model, opt, ar...
5,533
30.443182
120
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/optimization/__init__.py
0
0
0
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/utils/distributions.py
from __future__ import print_function import torch import torch.utils.data import math MIN_EPSILON = 1e-5 MAX_EPSILON = 1. - 1e-5 PI = torch.FloatTensor([math.pi]) if torch.cuda.is_available(): PI = PI.cuda() # N(x | mu, var) = 1/sqrt{2pi var} exp[-1/(2 var) (x-mean)(x-mean)] # log N(x| mu, var) = -log sqrt(2pi...
1,768
25.80303
86
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/utils/plotting.py
from __future__ import division from __future__ import print_function import numpy as np import matplotlib # noninteractive background matplotlib.use('Agg') import matplotlib.pyplot as plt def plot_training_curve(train_loss, validation_loss, fname='training_curve.pdf', labels=None): """ Plots train_loss and ...
4,021
37.304762
106
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/utils/log_likelihood.py
from __future__ import print_function import time import numpy as np from scipy.misc import logsumexp from ...vae_lib.optimization.loss import calculate_loss_array def calculate_likelihood(X, model, args, logger, S=5000, MB=500): # set auxiliary variables for number of training and test sets N_test = X.size(...
1,595
25.163934
110
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/utils/load_data.py
from __future__ import print_function import torch import torch.utils.data as data_utils import pickle from scipy.io import loadmat import numpy as np import os def load_static_mnist(args, **kwargs): """ Dataloading function for static mnist. Outputs image data in vectorized form: each image is a vector of...
7,580
35.800971
116
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/utils/__init__.py
0
0
0
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/vae_lib/utils/visual_evaluation.py
from __future__ import print_function import os import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec def plot_reconstructions(data, recon_mean, loss, loss_type, epoch, args): if args.input_type == 'multinomial': # data is already between 0 and 1 ...
2,063
37.222222
119
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/UMNN/spectral_normalization.py
# Code from https://github.com/christiancosgrove/pytorch-spectral-normalization-gan/blob/master/spectral_normalization.py import torch from torch import nn from torch.nn import Parameter def l2normalize(v, eps=1e-12): return v / (v.norm() + eps) def joint_gaussian(n_samp=1000): x2 = torch.distributions.Norm...
2,536
32.381579
121
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/UMNN/made.py
""" Implements Masked AutoEncoder for Density Estimation, by Germain et al. 2015 Re-implementation by Andrej Karpathy based on https://arxiv.org/abs/1502.03509 Modified by Antoine Wehenkel """ import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import math # -------------------------...
9,945
40.26971
151
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/UMNN/ParallelNeuralIntegral.py
import torch import numpy as np import math def _flatten(sequence): flat = [p.contiguous().view(-1) for p in sequence] return torch.cat(flat) if len(flat) > 0 else torch.tensor([]) def compute_cc_weights(nb_steps): lam = np.arange(0, nb_steps + 1, 1).reshape(-1, 1) lam = np.cos((lam @ lam.T) * math....
4,099
38.423077
138
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/UMNN/MonotonicNN.py
import torch import torch.nn as nn from .NeuralIntegral import NeuralIntegral from .ParallelNeuralIntegral import ParallelNeuralIntegral def _flatten(sequence): flat = [p.contiguous().view(-1) for p in sequence] return torch.cat(flat) if len(flat) > 0 else torch.tensor([]) class IntegrandNN(nn.Module): ...
1,957
34.6
145
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/UMNN/__init__.py
from .UMNNMAFFlow import UMNNMAFFlow from .MonotonicNN import MonotonicNN, IntegrandNN from .UMNNMAF import IntegrandNetwork, UMNNMAF from .made import MADE from .NeuralIntegral import NeuralIntegral from .ParallelNeuralIntegral import ParallelNeuralIntegral
258
42.166667
58
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/UMNN/NeuralIntegral.py
import torch import numpy as np import math def _flatten(sequence): flat = [p.contiguous().view(-1) for p in sequence] return torch.cat(flat) if len(flat) > 0 else torch.tensor([]) def compute_cc_weights(nb_steps): lam = np.arange(0, nb_steps + 1, 1).reshape(-1, 1) lam = np.cos((lam @ lam.T) * math....
2,840
31.284091
119
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/UMNN/UMNNMAF.py
import torch import torch.nn as nn from .NeuralIntegral import NeuralIntegral from .ParallelNeuralIntegral import ParallelNeuralIntegral import numpy as np import math from .made import MADE, ConditionnalMADE class ELUPlus(nn.Module): def __init__(self): super().__init__() self.elu = nn.ELU() de...
10,524
38.716981
129
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/models/UMNN/UMNNMAFFlow.py
import torch import torch.nn as nn from .UMNNMAF import EmbeddingNetwork, UMNNMAF import numpy as np import math class ListModule(object): def __init__(self, module, prefix, *args): """ The ListModule class is a container for multiple nn.Module. :nn.Module module: A module to add in the li...
5,656
36.217105
115
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/datasets/power.py
import numpy as np import datasets class POWER: class Data: def __init__(self, data): self.x = data.astype(np.float32) self.N = self.x.shape[0] def __init__(self): trn, val, tst = load_data_normalised() self.trn = self.Data(trn) self.val = self.Da...
1,940
24.88
108
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/datasets/download_datasets.py
# -*- coding: utf-8 -*- """ Created on Wed Apr 19 15:58:53 2017 @author: Chin-Wei # some code adapted from https://github.com/yburda/iwae/blob/master/download_mnist.py LSUN https://github.com/fyu/lsun """ import urllib import pickle import os import struct import numpy as np import gzip import time import urllib.requ...
9,226
31.60424
119
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/datasets/hepmass.py
import pandas as pd import numpy as np from collections import Counter from os.path import join import datasets class HEPMASS: """ The HEPMASS data set. http://archive.ics.uci.edu/ml/datasets/HEPMASS """ class Data: def __init__(self, data): self.x = data.astype(np.float32)...
2,730
28.365591
112
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/datasets/gas.py
import pandas as pd import numpy as np import datasets class GAS: class Data: def __init__(self, data): self.x = data.astype(np.float32) self.N = self.x.shape[0] def __init__(self): file = datasets.root + 'gas/ethylene_CO.pickle' trn, val, tst = load_data_...
1,672
21.917808
59
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/datasets/bsds300.py
import numpy as np import h5py import datasets class BSDS300: """ A dataset of patches from BSDS300. """ class Data: """ Constructs the dataset. """ def __init__(self, data): self.x = data[:] self.N = self.x.shape[0] def __init__(self): ...
663
17.971429
66
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/datasets/miniboone.py
import numpy as np import datasets class MINIBOONE: class Data: def __init__(self, data): self.x = data.astype(np.float32) self.N = self.x.shape[0] def __init__(self): file = datasets.root + 'miniboone/data.npy' trn, val, tst = load_data_normalised(file) ...
1,955
26.942857
96
py
STFTgrad
STFTgrad-main/adaptiveSTFT/UMNN/datasets/__init__.py
root = 'datasets/data/' from .power import POWER from .gas import GAS from .hepmass import HEPMASS from .miniboone import MINIBOONE from .bsds300 import BSDS300
162
19.375
32
py
STFTgrad
STFTgrad-main/adaptiveSTFT/adaptive_stft_utils/operators.py
import torch.autograd import torch import torch.nn.functional as F def dithering_int(n): if n == int(n): return int(n) return int(torch.bernoulli((n - int(n))) + int(n)) class SignPassGrad(torch.autograd.Function): @staticmethod def forward(ctx, input): return input.sign() @stat...
1,729
23.027778
87
py
STFTgrad
STFTgrad-main/adaptiveSTFT/adaptive_stft_utils/losses.py
import torch.autograd import torch import torch.nn.functional as F from .operators import clip_tensor_norm def kurtosis(rfft_magnitudes_sq): epsilon = 1e-7 max_norm = 0.1 kur_part = [ torch.sum(torch.pow(a, 2)) / (torch.pow(torch.sum(a), 2).unsqueeze(-1) + epsilon) for a in rfft_ma...
541
24.809524
93
py
STFTgrad
STFTgrad-main/adaptiveSTFT/adaptive_stft_utils/mappings.py
import math import sys import pathlib import torch import torch.nn as nn import torch.nn.functional as F sys.path.insert(0, pathlib.Path(__file__).parent.parent.parent.absolute()) from UMNN.models.UMNN import MonotonicNN # Monotonically increasing mapping class IdxToWindow(nn.Module): def __init__(self, signal_...
6,507
40.452229
216
py
TV-parameter-learning
TV-parameter-learning-master/main.py
# -*- coding: utf-8 -*- # # Copyright (C) 2022 Kristian Bredies ([email protected]) # Enis Chenchene ([email protected]) # Alireza Hosseini ([email protected]) # # This file is part of the example code repository for the paper: # # K. Br...
2,885
38
90
py
TV-parameter-learning
TV-parameter-learning-master/structures.py
# -*- coding: utf-8 -*- # # Copyright (C) 2022 Kristian Bredies ([email protected]) # Enis Chenchene ([email protected]) # Alireza Hosseini ([email protected]) # # This file is part of the example code repository for the paper: # # K. Br...
3,390
23.751825
93
py
TV-parameter-learning
TV-parameter-learning-master/experiments.py
# -*- coding: utf-8 -*- # # Copyright (C) 2022 Kristian Bredies ([email protected]) # Enis Chenchene ([email protected]) # Alireza Hosseini ([email protected]) # # This file is part of the example code repository for the paper: # # K. Br...
6,124
32.108108
94
py
TV-parameter-learning
TV-parameter-learning-master/train_quadratic_model.py
# -*- coding: utf-8 -*- # # Copyright (C) 2022 Kristian Bredies ([email protected]) # Enis Chenchene ([email protected]) # Alireza Hosseini ([email protected]) # # This file is part of the example code repository for the paper: # # K. Br...
5,435
34.298701
94
py
TV-parameter-learning
TV-parameter-learning-master/single_patch.py
# -*- coding: utf-8 -*- # # Copyright (C) 2022 Kristian Bredies ([email protected]) # Enis Chenchene ([email protected]) # Alireza Hosseini ([email protected]) # # This file is part of the example code repository for the paper: # # K. Br...
3,956
32.252101
89
py
TV-parameter-learning
TV-parameter-learning-master/data.py
# -*- coding: utf-8 -*- # # Copyright (C) 2022 Kristian Bredies ([email protected]) # Enis Chenchene ([email protected]) # Alireza Hosseini ([email protected]) # # This file is part of the example code repository for the paper: # # K. Br...
3,155
33.681319
86
py
TV-parameter-learning
TV-parameter-learning-master/train_constant_model.py
# -*- coding: utf-8 -*- # # Copyright (C) 2022 Kristian Bredies ([email protected]) # Enis Chenchene ([email protected]) # Alireza Hosseini ([email protected]) # # This file is part of the example code repository for the paper: # # K. Br...
4,346
32.438462
96
py
TV-parameter-learning
TV-parameter-learning-master/plots.py
# -*- coding: utf-8 -*- # # Copyright (C) 2022 Kristian Bredies ([email protected]) # Enis Chenchene ([email protected]) # Alireza Hosseini ([email protected]) # # This file is part of the example code repository for the paper: # # K. Br...
5,081
32.88
94
py
TV-parameter-learning
TV-parameter-learning-master/denoising.py
# -*- coding: utf-8 -*- # # Copyright (C) 2022 Kristian Bredies ([email protected]) # Enis Chenchene ([email protected]) # Alireza Hosseini ([email protected]) # # This file is part of the example code repository for the paper: # # K. Br...
4,600
33.081481
92
py
daanet
daanet-master/app.py
import sys from gpu_env import DEVICE_ID, MODEL_ID, CONFIG_SET from utils.helper import set_logger, parse_args, get_args_cli def run(): set_logger(model_id='%s:%s' % (DEVICE_ID, MODEL_ID)) followup_args = get_args_cli(sys.argv[3:]) if len(sys.argv) > 3 else None args = parse_args(sys.argv[2] if len(sys.a...
466
28.1875
102
py
daanet
daanet-master/api.py
import logging from tensorflow.python.framework.errors_impl import NotFoundError, InvalidArgumentError from gpu_env import ModeKeys, APP_NAME from utils.helper import build_model logger = logging.getLogger(APP_NAME) def train(args): # check run_mode if 'run_mode' in args: args.set_hparam('run_mode'...
1,758
32.826923
92
py
daanet
daanet-master/grid_search.py
import itertools import os import sys from ruamel.yaml import YAML from utils.helper import set_logger, fill_gpu_jobs, get_tmp_yaml def run(): logger = set_logger() with open('grid.yaml') as fp: settings = YAML().load(fp) test_set = sys.argv[1:] if len(sys.argv) > 1 else settings['common'][...
1,612
36.511628
108
py
daanet
daanet-master/gpu_env.py
import os from datetime import datetime from enum import Enum os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' os.environ['CUDA_DEVICE_ORDER'] = 'PCI_BUS_ID' IGNORE_PATTERNS = ('data', '*.pyc', 'CVS', '.git', 'tmp', '.svn', '__pycache__', '.gitignore', '.*.yaml') MODEL_ID = datetime.now().strftime("%m%d-%H%M%S") + ( os.e...
1,139
23.255319
105
py
daanet
daanet-master/nlp/match_blocks.py
import tensorflow as tf from nlp.nn import linear_logit, layer_norm from nlp.seq2seq.common import dropout, softmax_mask def Attention_match(context, query, context_mask, query_mask, num_units=None, scope='attention_match_block', reuse=None, **kwargs): with tf.variable_sco...
7,338
41.421965
108
py
daanet
daanet-master/nlp/nn.py
import tensorflow as tf initializer = tf.contrib.layers.variance_scaling_initializer(factor=1.0, mode='FAN_AVG', uniform=True, dtype=tf....
14,303
42.345455
119
py
daanet
daanet-master/nlp/__init__.py
0
0
0
py
daanet
daanet-master/nlp/encode_blocks.py
import tensorflow as tf from nlp.nn import initializer, regularizer, spatial_dropout, get_lstm_init_state, layer_norm def LSTM_encode(seqs, scope='lstm_encode_block', reuse=None, **kwargs): with tf.variable_scope(scope, reuse=reuse): batch_size = tf.shape(seqs)[0] _seqs = tf.transpose(seqs, [1, 0...
3,388
39.831325
110
py
daanet
daanet-master/nlp/seq2seq/pointer_generator.py
import tensorflow as tf from tensorflow.contrib.seq2seq.python.ops.attention_wrapper import _compute_attention from tensorflow.python.framework import ops from tensorflow.python.ops import math_ops # from tensorflow.contrib.rnn.python.ops.core_rnn_cell import _linear from tensorflow.python.ops.rnn_cell_impl import _zer...
22,126
49.061086
158
py
daanet
daanet-master/nlp/seq2seq/common.py
# coding=utf-8 import math import time import tensorflow as tf from tensorflow.python.ops.image_ops_impl import ResizeMethod from tensorflow.python.ops.rnn_cell_impl import LSTMStateTuple INF = 1e30 def initializer(): return tf.contrib.layers.variance_scaling_initializer(factor=1.0, ...
9,076
36.508264
110
py
daanet
daanet-master/nlp/seq2seq/__init__.py
0
0
0
py
daanet
daanet-master/nlp/seq2seq/rnn.py
# coding=utf-8 import tensorflow as tf import tensorflow.contrib as tc import gpu_env from .common import dropout, dense, get_var def single_rnn_cell(cell_name, num_units, is_train=None, keep_prob=0.75): """ Get a single rnn cell """ cell_name = cell_name.upper() if cell_name == "GRU": c...
10,472
40.7251
120
py
daanet
daanet-master/daanet/base.py
import json import os import tensorflow as tf from base import base_model from gpu_env import ModeKeys from model_utils.helper import LossCounter, get_filename from utils.eval_4.eval import compute_bleu_rouge from utils.helper import build_model # model controller class RCBase(base_model.BaseModel): def __init_...
7,115
42.656442
117
py
daanet
daanet-master/daanet/basic.py
"""Sequence-to-Sequence with attention model. """ import tensorflow as tf from tensorflow.python.layers import core as layers_core from gpu_env import ModeKeys, SummaryType from model_utils.helper import mblock from nlp.encode_blocks import LSTM_encode, CNN_encode from nlp.match_blocks import dot_attention, Transform...
30,506
51.238014
127
py
daanet
daanet-master/base/base_model.py
import importlib import json import logging import os from collections import defaultdict from math import ceil import numpy as np import tensorflow as tf from ruamel.yaml import YAML from gpu_env import ModeKeys, APP_NAME, SummaryType from model_utils.helper import mblock, partial_restore, sample_element_from_var ...
20,931
43.918455
118
py
daanet
daanet-master/base/base_io.py
import logging from typing import List from dataio_utils.helper import build_vocab from gpu_env import APP_NAME, ModeKeys class BaseDataIO: def __init__(self, args): self.args = args self.logger = logging.getLogger(APP_NAME) self.vocab = build_vocab(args.word_embedding_files) self...
866
31.111111
71
py
daanet
daanet-master/dataio_utils/helper.py
import copy import json import random import re def _tokenize(x): tokens = [v for v in re.findall(r"\w+|[^\w]", x, re.UNICODE) if len(v)] # fix last hanging space token_shifts = [] char_token_map = [] c, j = 0, 0 for v in tokens: if v.strip(): token_shifts.append(j) ...
2,653
30.975904
110
py
daanet
daanet-master/dataio_utils/full_load_io.py
import random from base import base_io from gpu_env import ModeKeys class DataIO(base_io.BaseDataIO): def __init__(self, args): super().__init__(args) if args.is_serving: self.logger.info('model is serving request, ignoring train & dev sets!') else: self.datasets =...
2,018
34.421053
86
py
daanet
daanet-master/dataio_utils/flow_io.py
import json from typing import List import tensorflow as tf from base import base_io from gpu_env import ModeKeys # dataio controller class FlowDataIO(base_io.BaseDataIO): def __init__(self, args): super().__init__(args) if args.is_serving: self.logger.info('model is serving request,...
2,238
31.449275
98
py
daanet
daanet-master/dataio_utils/__init__.py
0
0
0
py
daanet
daanet-master/utils/predictor.py
import os import re import sys import tensorflow as tf from gpu_env import MODEL_ID MODEL_PATH = './ext' print(sys.path) class Predictor: def __init__(self, batch_size=32): self.batch_size = batch_size print("Loading model..., please wait!", flush=True) self.models, self.graphs, self.m...
3,379
29.178571
101
py
daanet
daanet-master/utils/helper.py
import importlib import logging import math import os import re import shutil import subprocess import sys import time import traceback from collections import defaultdict from random import shuffle import GPUtil import tensorflow as tf from ruamel.yaml import YAML from ruamel.yaml.comments import CommentedMap from te...
11,978
32
113
py
daanet
daanet-master/utils/vocab.py
import logging import pickle import numpy as np from gpu_env import APP_NAME class Vocab: @staticmethod def load_from_pickle(fp): with open(fp, 'rb') as fin: return pickle.load(fin) def __init__(self, embedding_files, lower=True): self.logger = logging.getLogger(APP_NAME) ...
5,793
34.987578
117
py
daanet
daanet-master/utils/__init__.py
0
0
0
py
daanet
daanet-master/utils/eval_4/eval.py
from .bleu_metric.bleu import Bleu from .exact_f1.exact_f1 import f1_exact_eval from .meteor.meter import compute_meter_score from .rouge_metric.rouge import Rouge def normalize(s): """ Normalize strings to space joined chars. Args: s: a list of strings. Returns: A list of normalized...
1,497
28.96
79
py
daanet
daanet-master/utils/eval_4/__init__.py
0
0
0
py
daanet
daanet-master/utils/eval_4/meteor/__init__.py
__author__ = 'larryjfyan'
26
12.5
25
py
daanet
daanet-master/utils/eval_4/meteor/meter.py
import os def compute_meter_score(pred, ref): cwd = os.path.dirname(__file__) test_path = '{}/test'.format(cwd) ref_path = '{}/reference'.format(cwd) jar_path = '{}/meteor-1.5.jar'.format(cwd) save_path = '{}/res.txt'.format(cwd) with open(test_path, 'w') as f: f.write('\n'.join(pred))...
635
30.8
108
py
daanet
daanet-master/utils/eval_4/exact_f1/exact_f1.py
"""Official evaluation script for SQuAD version 2.0. In addition to basic functionality, we also compute additional statistics and plot precision-recall curves if an additional na_prob.json file is provided. This file is expected to map question ID's to the model's predicted probability that a question is unanswerable...
2,407
31.986301
82
py
daanet
daanet-master/utils/eval_4/exact_f1/__init__.py
0
0
0
py
daanet
daanet-master/utils/eval_4/rouge_metric/rouge.py
#!/usr/bin/env python # # File Name : rouge.py # # Description : Computes ROUGE-L metric as described by Lin and Hovey (2004) # # Creation Date : 2015-01-07 06:03 # Author : Ramakrishna Vedantam <[email protected]> import numpy as np def my_lcs(string, sub): """ Calculates longest common subsequence for a pair...
3,391
35.085106
123
py
daanet
daanet-master/utils/eval_4/rouge_metric/__init__.py
0
0
0
py
daanet
daanet-master/utils/eval_4/bleu_metric/bleu_scorer.py
#!/usr/bin/env python # bleu_scorer.py # David Chiang <[email protected]> # Copyright (c) 2004-2006 University of Maryland. All rights # reserved. Do not redistribute without permission from the # author. Not for commercial use. # Modified by: # Hao Fang <[email protected]> # Tsung-Yi Lin <[email protected]> '''Provides: ...
8,791
31.442804
150
py
daanet
daanet-master/utils/eval_4/bleu_metric/bleu.py
#!/usr/bin/env python # # File Name : bleu.py # # Description : Wrapper for BLEU scorer. # # Creation Date : 06-01-2015 # Last Modified : Thu 19 Mar 2015 09:13:28 PM PDT # Authors : Hao Fang <[email protected]> and Tsung-Yi Lin <[email protected]> from .bleu_scorer import BleuScorer class Bleu: def __init__(self, n=...
1,297
27.844444
80
py
daanet
daanet-master/utils/eval_4/bleu_metric/__init__.py
0
0
0
py
daanet
daanet-master/model_utils/helper.py
import json import logging import os import time import tensorflow as tf from gpu_env import APP_NAME, ModeKeys def sample_element_from_var(all_var): result = {} for v in all_var: try: v_rank = len(v.get_shape()) v_ele1, v_ele2 = v, v for j in range(v_rank): ...
4,728
35.099237
107
py
daanet
daanet-master/model_utils/__init__.py
0
0
0
py
Tim-TSENet
Tim-TSENet-main/TSENET/test_tasnet.py
import os import torch from data_loader.AudioReader import AudioReader, write_wav import argparse from model.model import TSENet,TSENet_one_hot from logger.set_logger import setup_logger import logging from config.option import parse import torchaudio from utils.util import handle_scp, handle_scp_inf def read_wav(fnam...
7,559
48.090909
176
py
Tim-TSENet
Tim-TSENet-main/TSENET/train_Tasnet.py
import sys sys.path.append('./') from torch.utils.data import DataLoader as Loader from data_loader.Dataset import Datasets from model.model import TSENet,TSENet_one_hot from logger import set_logger import logging from config import option import argparse import torch from trainer import trainer_Tasnet,trainer_Tasnet_...
7,435
48.245033
131
py