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
ParallelWaveGAN
ParallelWaveGAN-master/test/test_layers.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) import logging import numpy as np import pytest import torch from parallel_wavegan.layers import ( PQMF, CausalConv1d, CausalConvTranspose1d, Conv1d, Conv1d1x1, ...
4,085
26.059603
84
py
ParallelWaveGAN
ParallelWaveGAN-master/test/test_mel_loss.py
#!/usr/bin/env python3 # Copyright 2021 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Test code for Mel-spectrogram loss modules.""" import numpy as np import torch from parallel_wavegan.bin.preprocess import logmelfilterbank from parallel_wavegan.losses import MelSpectrogram def test_me...
1,117
22.787234
65
py
ParallelWaveGAN
ParallelWaveGAN-master/test/test_hifigan.py
#!/usr/bin/env python3 # Copyright 2021 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Test code for HiFi-GAN modules.""" import logging import os import numpy as np import pytest import torch import yaml from test_parallel_wavegan import make_mutli_reso_stft_loss_args import parallel_waveg...
7,403
28.854839
85
py
ParallelWaveGAN
ParallelWaveGAN-master/test/test_melgan.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) import logging import numpy as np import pytest import torch from test_parallel_wavegan import ( make_discriminator_args, make_mutli_reso_stft_loss_args, make_residual_discr...
9,711
31.15894
86
py
ParallelWaveGAN
ParallelWaveGAN-master/test/test_parallel_wavegan.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) import logging import numpy as np import pytest import torch from parallel_wavegan.losses import ( DiscriminatorAdversarialLoss, GeneratorAdversarialLoss, MultiResolutionST...
10,809
29.111421
86
py
ParallelWaveGAN
ParallelWaveGAN-master/test/test_style_melgan.py
#!/usr/bin/env python3 # Copyright 2021 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Test code for StyleMelGAN modules.""" import logging import numpy as np import pytest import torch from test_parallel_wavegan import make_mutli_reso_stft_loss_args from parallel_wavegan.losses import ( ...
5,057
27.576271
82
py
ParallelWaveGAN
ParallelWaveGAN-master/egs/vctk/vq1/local/decode_from_text.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Decode text with trained VQ-VAE Generator or discrete symbol vocoder.""" import argparse import logging import os import time import soundfile as sf import torch import yaml from tq...
5,353
29.420455
84
py
ParallelWaveGAN
ParallelWaveGAN-master/egs/cvss_c/voc1/local/decode_from_text.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Decode text with trained VQ-VAE Generator or discrete symbol vocoder.""" import argparse import logging import os import time import soundfile as sf import torch import yaml from tq...
5,294
28.416667
85
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/functions/vector_quantizer.py
# -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Vector quantization modules. These codes are modified from https://github.com/ritheshkumar95/pytorch-vqvae. """ import torch from torch.autograd import Function class VectorQuantization(Function): ...
3,630
30.573913
83
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/models/parallel_wavegan.py
# -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Parallel WaveGAN Modules.""" import logging import math import numpy as np import torch from parallel_wavegan import models from parallel_wavegan.layers import Conv1d, Conv1d1x1 from parallel_wavegan.lay...
18,221
34.313953
88
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/models/vqvae.py
# -*- coding: utf-8 -*- # Copyright 2020 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """VQVAE Modules.""" import logging import torch import parallel_wavegan.models from parallel_wavegan.layers import VQCodebook class VQVAE(torch.nn.Module): """VQVAE module.""" def __init__( ...
6,165
34.848837
97
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/models/melgan.py
# -*- coding: utf-8 -*- # Copyright 2020 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """MelGAN Modules.""" import logging import numpy as np import torch from parallel_wavegan.layers import CausalConv1d, CausalConvTranspose1d, ResidualStack from parallel_wavegan.utils import read_hdf5 cla...
18,873
34.278505
106
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/models/hifigan.py
# -*- coding: utf-8 -*- """HiFi-GAN Modules. This code is based on https://github.com/jik876/hifi-gan. """ import copy import logging import numpy as np import torch import torch.nn.functional as F from parallel_wavegan.layers import CausalConv1d, CausalConvTranspose1d from parallel_wavegan.layers import HiFiGANR...
47,878
36.115504
108
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/models/style_melgan.py
# Copyright 2021 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """StyleMelGAN Modules.""" import copy import logging import numpy as np import torch import torch.nn.functional as F from parallel_wavegan.layers import PQMF, TADEResBlock from parallel_wavegan.models import MelGANDiscriminator as...
20,714
33.353234
103
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/models/tf_models.py
# -*- coding: utf-8 -*- # Copyright 2020 MINH ANH (@dathudeptrai) # MIT License (https://opensource.org/licenses/MIT) """Tensorflow MelGAN modules complatible with pytorch.""" import numpy as np import tensorflow as tf from parallel_wavegan.layers.tf_layers import ( TFConvTranspose1d, TFReflectionPad1d, ...
4,922
34.417266
102
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/models/uhifigan.py
# -*- coding: utf-8 -*- """Unet-baed HiFi-GAN Modules. This code is based on https://github.com/jik876/hifi-gan. """ import logging import numpy as np import torch from parallel_wavegan.layers import CausalConv1d, CausalConvTranspose1d from parallel_wavegan.layers import HiFiGANResidualBlock as ResidualBlock from...
14,674
36.822165
98
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/bin/decode.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Decode with trained Parallel WaveGAN Generator.""" import argparse import logging import os import time import numpy as np import soundfile as sf import torch import yaml from tqdm ...
13,111
34.342318
87
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/bin/train.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Train Parallel WaveGAN.""" import argparse import logging import os import sys from collections import defaultdict import matplotlib import numpy as np import soundfile as sf import...
59,276
37.218569
110
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/bin/preprocess.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Perform preprocessing and raw feature extraction.""" import argparse import logging import os import librosa import numpy as np import soundfile as sf import torch import yaml from...
16,741
30.410882
93
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/distributed/launch.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Distributed process launcher. This code is modified from https://github.com/pytorch/pytorch/blob/v1.3.0/torch/distributed/launch.py. """ import os import subprocess import sys from argparse import REMAINDER, ArgumentParser def parse_args(): """Parse arguments."...
5,262
28.903409
102
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/datasets/audio_mel_dataset.py
# -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Dataset modules.""" import logging import os from multiprocessing import Manager import numpy as np from torch.utils.data import Dataset from parallel_wavegan.utils import find_files, read_hdf5 class A...
27,965
35.894459
99
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/datasets/scp_dataset.py
# -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Dataset modules based on kaldi-style scp files.""" import logging from multiprocessing import Manager import kaldiio import numpy as np from torch.utils.data import Dataset from parallel_wavegan.utils im...
11,431
31.202817
101
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/residual_stack.py
# -*- coding: utf-8 -*- # Copyright 2020 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Residual stack module in MelGAN.""" import torch from parallel_wavegan.layers import CausalConv1d class ResidualStack(torch.nn.Module): """Residual stack module introduced in MelGAN.""" def __i...
3,073
34.744186
88
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/pqmf.py
# -*- coding: utf-8 -*- # Copyright 2020 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Pseudo QMF modules.""" import numpy as np import torch import torch.nn.functional as F from scipy.signal import kaiser def design_prototype_filter(taps=62, cutoff_ratio=0.142, beta=9.0): """Design pr...
4,907
31.72
103
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/tf_layers.py
# -*- coding: utf-8 -*- # Copyright 2020 MINH ANH (@dathudeptrai) # MIT License (https://opensource.org/licenses/MIT) """Tensorflow Layer modules complatible with pytorch.""" import tensorflow as tf class TFReflectionPad1d(tf.keras.layers.Layer): """Tensorflow ReflectionPad1d module.""" def __init__(self...
3,916
26.780142
88
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/duration_predictor.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # 2023 Jiatong Shi # Adapted from ESPnet fastspeech duration predictor # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Duration predictor related modules.""" import torch from parallel_wavegan.layers.layer_norm i...
3,820
31.65812
88
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/tade_res_block.py
# Copyright 2021 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """StyleMelGAN's TADEResBlock Modules.""" from functools import partial import torch class TADELayer(torch.nn.Module): """TADE Layer module.""" def __init__( self, in_channels=64, aux_channels=80, ...
4,805
28.850932
88
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/sine.py
"""Sing generator.""" import numpy as np import torch class SineGen(torch.nn.Module): """Definition of sine generator.""" def __init__( self, samp_rate, harmonic_num=0, sine_amp=0.1, noise_std=0.003, voiced_threshold=0, flag_for_pulse=False, ): ...
5,554
36.789116
103
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/residual_block.py
# -*- coding: utf-8 -*- """Residual block modules. References: - https://github.com/r9y9/wavenet_vocoder - https://github.com/jik876/hifi-gan """ import math import torch import torch.nn.functional as F from parallel_wavegan.layers.causal_conv import CausalConv1d class Conv1d(torch.nn.Conv1d): """Co...
8,832
33.104247
102
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/variance_predictor.py
#!/usr/bin/env python3 # Copyright 2020 Tomoki Hayashi # 2023 Jiatong Shi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Variance predictor related modules.""" import torch from typeguard import check_argument_types from parallel_wavegan.layers.layer_norm import LayerNorm class VarianceP...
2,637
28.977273
86
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/causal_conv.py
# -*- coding: utf-8 -*- # Copyright 2020 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Causal convolusion layer modules.""" import torch class CausalConv1d(torch.nn.Module): """CausalConv1d module with customized initialization.""" def __init__( self, in_channels,...
2,162
26.379747
85
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/layer_norm.py
"""LayerNorm for specific dimensions. Adapted from ESPnet Transformer LayerNorm. """ import torch class LayerNorm(torch.nn.LayerNorm): """Layer normalization module. Args: nout (int): Output dim size. dim (int): Dimension to be normalized. """ def __init__(self, nout, dim=-1): ...
870
20.243902
56
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/vector_quantize_codebook.py
# -*- coding: utf-8 -*- # Copyright 2020 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Vector quantize codebook modules. This code is modified from https://github.com/ritheshkumar95/pytorch-vqvae. """ import torch from parallel_wavegan.functions import vector_quantize, vector_quantize_str...
2,132
28.219178
88
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/upsample.py
# -*- coding: utf-8 -*- """Upsampling module. This code is modified from https://github.com/r9y9/wavenet_vocoder. """ import numpy as np import torch import torch.nn.functional as F from parallel_wavegan.layers import Conv1d class Stretch2d(torch.nn.Module): """Stretch2d module.""" def __init__(self, x_...
6,489
32.282051
92
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/layers/length_regulator.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # 2023 Jiatong Shi # Adapated from ESPnet Fastspeech LengthRegulator # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Length regulator related modules.""" import logging import torch def pad_list(xs, pad_value)...
2,984
29.151515
87
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/optimizers/radam.py
# -*- coding: utf-8 -*- """RAdam optimizer. This code is drived from https://github.com/LiyuanLucasLiu/RAdam. """ import math import torch from torch.optim.optimizer import Optimizer class RAdam(Optimizer): """Rectified Adam optimizer.""" def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, ...
3,632
35.33
87
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/optimizers/__init__.py
from torch.optim import * # NOQA from .radam import * # NOQA
64
15.25
33
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/utils/utils.py
# -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Utility functions.""" import fnmatch import logging import os import re import sys import tarfile from distutils.version import LooseVersion import h5py import numpy as np import torch import yaml from fi...
14,086
32.381517
102
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/losses/stft_loss.py
# -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """STFT-based Loss modules.""" from distutils.version import LooseVersion import torch import torch.nn.functional as F is_pytorch_17plus = LooseVersion(torch.__version__) >= LooseVersion("1.7") def stft(x...
5,471
31
97
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/losses/duration_prediction_loss.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # 2023 Jiatong SHi # Adapted from espnet/espnet/net/pytorch_backend/duration_predictor.py # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Duration predictor related modules.""" import torch class DurationPredict...
1,534
27.962264
88
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/losses/adversarial_loss.py
# -*- coding: utf-8 -*- # Copyright 2021 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Adversarial loss modules.""" import torch import torch.nn.functional as F class GeneratorAdversarialLoss(torch.nn.Module): """Generator adversarial loss module.""" def __init__( self, ...
4,133
32.33871
84
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/losses/mel_loss.py
# Copyright 2021 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Mel-spectrogram loss modules.""" from distutils.version import LooseVersion import librosa import torch import torch.nn.functional as F is_pytorch_17plus = LooseVersion(torch.__version__) >= LooseVersion("1.7") class MelSpectr...
4,625
26.86747
81
py
ParallelWaveGAN
ParallelWaveGAN-master/parallel_wavegan/losses/feat_match_loss.py
# -*- coding: utf-8 -*- # Copyright 2021 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Feature matching loss modules.""" import torch import torch.nn.functional as F class FeatureMatchLoss(torch.nn.Module): """Feature matching loss module.""" def __init__( self, av...
1,746
30.763636
76
py
BanditZoo
BanditZoo-main/docs/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
2,160
32.765625
79
py
AtLoc
AtLoc-master/eval.py
import os os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2,3,4,5,6,7" import torch import os.path as osp import numpy as np import matplotlib import sys DISPLAY = 'DISPLAY' in os.environ if not DISPLAY: matplotlib.use('Agg') import matplotlib.pyplot as plt from tools.opt...
4,997
35.75
143
py
AtLoc
AtLoc-master/train.py
import os os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2,3,4,5,6,7" import torch import sys import time import os.path as osp import numpy as np from tensorboardX import SummaryWriter from tools.options import Options from network.atloc import AtLoc, AtLocPlus from torchvis...
7,019
42.333333
187
py
AtLoc
AtLoc-master/tools/saliency_map.py
import os os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2,3,4,5,6,7" import torch import os.path as osp import numpy as np import matplotlib import sys import cv2 from tools.options import Options DISPLAY = 'DISPLAY' in os.environ if not DISPLAY: matplotlib.use('Agg') im...
3,971
30.52381
143
py
AtLoc
AtLoc-master/tools/utils.py
import os import torch from torch import nn import scipy.linalg as slin import math import transforms3d.quaternions as txq import transforms3d.euler as txe import numpy as np import sys from torch.nn import Module from torch.autograd import Variable from torch.nn.functional import pad from torchvision.datasets.folder ...
6,007
31.652174
142
py
AtLoc
AtLoc-master/tools/options.py
import argparse import os from tools import utils import torch class Options(): def __init__(self): self.parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) def initialize(self): # base options self.parser.add_argument('--data_dir', type=str, defaul...
3,916
49.217949
126
py
AtLoc
AtLoc-master/network/att.py
import torch from torch import nn from torch.nn import functional as F class AttentionBlock(nn.Module): def __init__(self, in_channels): super(AttentionBlock, self).__init__() self.g = nn.Linear(in_channels, in_channels // 8) self.theta = nn.Linear(in_channels, in_channels // 8) se...
996
31.16129
70
py
AtLoc
AtLoc-master/network/atloc.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.init from network.att import AttentionBlock class FourDirectionalLSTM(nn.Module): def __init__(self, seq_size, origin_feat_size, hidden_size): super(FourDirectionalLSTM, self).__init__() self.feat_size = origin_feat_...
3,584
37.138298
109
py
AtLoc
AtLoc-master/data/dataset_mean.py
import os.path as osp import numpy as np from data.dataloaders import RobotCar, SevenScenes from torchvision import transforms from torch.utils.data import DataLoader from tools.options import Options opt = Options().parse() data_transform = transforms.Compose([ transforms.Resize(opt.cropsize), transforms.Ra...
1,592
29.634615
104
py
AtLoc
AtLoc-master/data/dataloaders.py
import os import torch import numpy as np import pickle import os.path as osp from data.robotcar_sdk.interpolate_poses import interpolate_vo_poses, interpolate_ins_poses from data.robotcar_sdk.camera_model import CameraModel from data.robotcar_sdk.image import load_image as robotcar_loader from tools.utils import proc...
12,124
39.416667
160
py
AtLoc
AtLoc-master/data/process_robotcar.py
import os.path as osp import numpy as np from PIL import Image from data.dataloaders import RobotCar from torch.utils.data import DataLoader from torchvision import transforms from tools.options import Options opt = Options().parse() if opt.val: print('processing VAL data using {:d} cores'.format(opt.nThreads)) ...
1,998
35.345455
112
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_ae/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
1,965
31.766667
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_ae/dataloader.py
# coding: utf-8 import numpy as np import torch import torch.utils.data import torchvision import torchvision.models from torchvision import transforms from torchvision import datasets def get_loader(dataset, batch_size, num_workers): if dataset == "mnist": return get_mnist_loader(batch_size, num_worke...
5,910
31.300546
95
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_ae/utils.py
import enum import os import logging import io from random import random import warnings from matplotlib.colors import ListedColormap import numpy as np import torch import torch.nn as nn from torchvision.utils import make_grid from sklearn.decomposition import PCA from sklearn.manifold import TSNE import matplotlib.p...
6,717
29.675799
108
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_ae/create_loss_surface.py
from __future__ import print_function import argparse from email.mime import base import os import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torch.optim.lr_scheduler import StepLR from torchmetrics.functional import ssim as ...
8,623
32.952756
136
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_ae/autoencoder.py
# coding: utf-8 from typing import Dict, List, NewType, Optional, Tuple, Union import numpy as np import torch import torch.nn as nn import torch.nn.functional as F ##################### ###### MODULES ###### ##################### class Encoder(nn.Module): def __init__( self, width: int = 256, ...
10,963
26.138614
193
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_ae/train.py
#!/usr/bin/env python # coding: utf-8 from configparser import ParsingError from enum import auto from json import encoder import os import time import importlib import json from collections import OrderedDict import logging import argparse import numpy as np import random import wandb import torch import torch.nn as...
12,920
30.36165
136
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_resnet/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
2,157
31.208955
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_resnet/resnet.py
# coding: utf-8 import torch import torch.nn as nn import torch.nn.functional as F def initialize_weights(module): if isinstance(module, nn.Conv2d): nn.init.kaiming_normal_(module.weight.data, mode='fan_out') elif isinstance(module, nn.BatchNorm2d): module.weight.data.fill_(1) module....
8,024
29.865385
78
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_resnet/dataloader.py
# coding: utf-8 import numpy as np import torch import torch.utils.data import torchvision import torchvision.models from torchvision import transforms from torchvision import datasets def get_loader(dataset, batch_size, num_workers): if dataset == "mnist": return get_mnist_loader(batch_size, num_worke...
8,138
32.9125
104
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_resnet/train.py
#!/usr/bin/env python # coding: utf-8 # From https://github.dev/hysts/pytorch_resnet/blob/master/main.py from email.policy import default import os import time import importlib import json from collections import OrderedDict import logging import argparse import numpy as np import random import wandb import torch im...
10,646
29.682997
136
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_fnn/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
2,157
31.208955
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_fnn/train.py
from __future__ import print_function import argparse import torch import copy import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torch_optimizer as optim_special from torchvision import datasets, transforms from torch.optim.lr_scheduler import StepLR from batch_entropy import batc...
8,759
38.638009
125
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_neuron_dist/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
2,157
31.208955
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_neuron_dist/train.py
from __future__ import print_function import argparse import torch import copy import torch.nn as nn from random import randint import torch.nn.functional as F import torch.optim as optim import torch_optimizer as optim_special from torchvision import datasets, transforms from torch.optim.lr_scheduler import StepLR fro...
8,566
36.08658
121
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_info_flow/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
2,157
31.208955
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_info_flow/train.py
from __future__ import print_function import argparse import torch import copy import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torch_optimizer as optim_special from torchvision import datasets, transforms from torch.optim.lr_scheduler import StepLR from batch_entropy import batc...
7,561
38.181347
124
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_normalization/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
2,157
31.208955
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_normalization/train.py
from __future__ import print_function import os os.environ["CUDA_VISIBLE_DEVICES"] = "0" import argparse from typing import Dict import torch import copy import torch.nn as nn import torch.nn.functional as F from torch.nn.utils.weight_norm import weight_norm import torch.optim as optim import torch_optimizer as optim...
9,979
38.760956
177
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_deep_vanilla_fnn/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
2,157
31.208955
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_deep_vanilla_fnn/train.py
from __future__ import print_function import argparse import torch import copy import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torch_optimizer as optim_special from torchvision import datasets, transforms from torch.optim.lr_scheduler import StepLR from batch_entropy import batc...
9,103
39.283186
159
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_transformer/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
2,157
31.208955
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_transformer/run_glue.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2020 The HuggingFace Inc. 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/LI...
27,224
40.063348
145
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_transformer/models/bert/modeling_bert.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
80,584
41.682733
213
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_loss_surface/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
2,157
31.208955
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_loss_surface/utils.py
import torch import numpy as np import copy # Thanks to https://gitlab.com/qbeer/loss-landscape/-/blob/main/loss_landscape/landscape_utils.py def init_directions(model): noises = [] n_params = 0 for name, param in model.named_parameters(): delta = torch.normal(.0, 1, size=param.size()) nu...
1,013
23.731707
97
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_loss_surface/create_loss_surface.py
from __future__ import print_function import argparse import os import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torch.optim.lr_scheduler import StepLR from batch_entropy import batch_entropy, LBELoss, CELoss import time imp...
7,982
35.122172
125
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_deep_vanilla_cnn/batch_entropy.py
import torch from torch import nn import torch.nn.functional as F import numpy as np import scipy import scipy.stats import random def batch_entropy(x): """ Estimate the differential entropy by assuming a gaussian distribution of values for different samples of a mini-batch. """ if(x.shape[0] <= 1...
2,157
31.208955
113
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_deep_vanilla_cnn/delta_orth.py
import math import torch """ The implementation below corresponds to Tensorflow implementation. Refer https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/init_ops.py for details. From https://github.com/yl-1993/ConvDeltaOrthogonal-Init/ We tried this version as well as the version ...
2,997
35.120482
109
py
layerwise-batch-entropy
layerwise-batch-entropy-main/experiment_deep_vanilla_cnn/train.py
from __future__ import print_function import os os.environ["CUDA_VISIBLE_DEVICES"] = "0" import argparse import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from delta_orth import init_delta_orthogonal_1, init_delta_orthogonal_2 from torchvision import datasets, transforms...
11,081
38.72043
159
py
swav
swav-main/eval_linear.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import argparse import os import time from logging import getLogger import torch import torch.nn as nn import torch.nn.p...
13,429
33.260204
104
py
swav
swav-main/main_deepclusterv2.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import argparse import math import os import shutil import time from logging import getLogger import numpy as np import ...
17,265
39.625882
123
py
swav
swav-main/hubconf.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import torch from torchvision.models.resnet import resnet50 as _resnet50 from src.resnet50 import resnet50w2 as _resnet50...
2,830
31.54023
96
py
swav
swav-main/eval_semisup.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import argparse import os import time from logging import getLogger import urllib import torch import torch.nn as nn imp...
12,149
33.615385
165
py
swav
swav-main/main_swav.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import argparse import math import os import shutil import time from logging import getLogger import numpy as np import t...
14,998
38.367454
123
py
swav
swav-main/src/multicropdataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import random from logging import getLogger from PIL import ImageFilter import numpy as np import torchvision.datasets as...
3,029
30.894737
76
py
swav
swav-main/src/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import argparse from logging import getLogger import pickle import os import numpy as np import torch from .logger impo...
5,506
26.954315
102
py
swav
swav-main/src/resnet50.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import torch import torch.nn as nn def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): """3x3 convo...
11,025
30.146893
106
py
GPSKet
GPSKet-master/GPSKet/__init__.py
# enable x64 on jax # must be done at 0 startup. from jax.config import config config.update("jax_enable_x64", True) del config __all__ = [ "models", "nn", "operator", "optimizer", "sampler", "hilbert", "driver", "datasets", "vqs" ] from . import models from . import nn from . imp...
462
15.535714
37
py
GPSKet
GPSKet-master/GPSKet/nn/initializers.py
import jax import jax.numpy as jnp from jax import dtypes def normal(sigma=0.1, dtype=jnp.float_): """ Constructs an initializer for a qGPS model. Real parameters are normally distributed around 1.0, while complex parameters have unit length and have normally distributed phases around 0. Args: ...
1,960
34.654545
102
py
GPSKet
GPSKet-master/GPSKet/nn/causal_conv.py
import numpy as np import jax.numpy as jnp from flax import linen as nn from jax.nn.initializers import lecun_normal, zeros from netket.utils.types import Callable, DType, Array, NNInitFunc default_kernel_init = lecun_normal() # Part of the code was inspired by the tutorial on autoregressive image modelling at # htt...
4,957
31.618421
120
py
GPSKet
GPSKet-master/GPSKet/sampler/autoreg.py
import jax import numpy as np from jax import numpy as jnp from functools import partial from netket.sampler import Sampler, SamplerState from netket.utils import struct, HashableArray from netket.utils.types import PRNGKeyT def batch_choice(key, a, p): """ Batched version of `jax.random.choice`. Attribu...
5,605
31.593023
158
py
GPSKet
GPSKet-master/GPSKet/sampler/metropolis_fast.py
import jax import jax.numpy as jnp from netket.utils import struct from netket.sampler.metropolis import MetropolisSampler, MetropolisRule from netket.sampler.rules.exchange import compute_clusters class MetropolisRuleWithUpdate(MetropolisRule): pass @struct.dataclass class MetropolisFastSampler(MetropolisSampler...
4,198
40.574257
169
py
GPSKet
GPSKet-master/GPSKet/sampler/rules/exchange_with_update.py
import jax import jax.numpy as jnp from flax import struct from netket.sampler.rules.exchange import ExchangeRule_ @struct.dataclass class ExchangeRuleWithUpdate(ExchangeRule_): """ Exchange Update rule which also returns the list of affected sites which is required for the fast metropolis sampler """ ...
1,055
33.064516
120
py
GPSKet
GPSKet-master/GPSKet/sampler/rules/fermionic_hopping.py
import jax import jax.numpy as jnp from flax import struct from netket.sampler.metropolis import MetropolisRule from typing import Optional from netket.utils.types import Array def transition_function(key, sample, hop_probability, transition_probs=None, return_updates=False): def apply_electron_hop(samp, key): ...
3,703
49.739726
177
py
GPSKet
GPSKet-master/GPSKet/operator/hamiltonian/ab_initio_sparse.py
import numpy as np import netket as nk import jax.numpy as jnp import jax from numba import jit import netket.jax as nkjax from typing import Optional from functools import partial from GPSKet.operator.hamiltonian.ab_initio import AbInitioHamiltonianOnTheFly, get_parity_multiplicator_hop from netket.utils.types imp...
15,532
54.27758
170
py
GPSKet
GPSKet-master/GPSKet/operator/hamiltonian/J1J2.py
import jax import jax.numpy as jnp import netket as nk import netket.jax as nkjax from netket.vqs.mc.mc_state.state import MCState from GPSKet.models import qGPS import GPSKet.vqs.mc.mc_state.expect from typing import Optional # dummy class used if the local energy should be evaluated on the fly (allowing for fast up...
4,803
47.525253
159
py