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
trVAE_reproducibility
trVAE_reproducibility-master/reptrvae/models/_scvi.py
import os import numpy as np import scanpy as sc import torch from scvi.dataset import AnnDatasetFromAnnData from scvi.inference import UnsupervisedTrainer from scvi.models import * from sklearn.preprocessing import LabelEncoder from reptrvae.models._network import Network class scVI(Network): def __init__(self...
5,113
37.742424
125
py
trVAE_reproducibility
trVAE_reproducibility-master/reptrvae/models/_losses.py
import tensorflow as tf from keras import backend as K, Model from keras.applications.imagenet_utils import preprocess_input # from keras_vggface import VGGFace from ._utils import compute_mmd, _nelem, _nan2zero, _nan2inf, _reduce_mean def kl_recon(mu, log_var, alpha=0.1, eta=1.0): def kl_recon_loss(y_true, y_pr...
6,436
32.180412
109
py
trVAE_reproducibility
trVAE_reproducibility-master/reptrvae/models/_cycle_gan.py
import logging import os import anndata import keras import numpy as np from keras.layers import Input, Dense, BatchNormalization, LeakyReLU, Dropout, ReLU from keras.models import Model, load_model from keras.optimizers import Adam from reptrvae.models._network import Network from reptrvae.utils import remove_sparsi...
10,714
41.689243
115
py
trVAE_reproducibility
trVAE_reproducibility-master/reptrvae/models/_dctrvae.py
import logging import os import anndata import keras import numpy as np from keras.callbacks import CSVLogger, History, EarlyStopping, ReduceLROnPlateau, LambdaCallback from keras.layers import Activation from keras.layers import Dense, BatchNormalization, Dropout, Input, concatenate, Lambda, Conv2D, \ Flatten, Re...
28,732
49.408772
193
py
trVAE_reproducibility
trVAE_reproducibility-master/reptrvae/models/_mmdcvae.py
import logging import os import anndata import keras import numpy as np from keras.callbacks import CSVLogger, History, EarlyStopping, ReduceLROnPlateau, LambdaCallback from keras.layers import Dense, BatchNormalization, Dropout, Input, concatenate, Lambda, Activation from keras.layers.advanced_activations import Leak...
19,700
47.05122
193
py
trVAE_reproducibility
trVAE_reproducibility-master/reptrvae/bin/DataDownloader.py
import os import wget url_dict = { "train_pbmc": "https://www.dropbox.com/s/wk5zewf2g1oat69/train_pbmc.h5ad?dl=1", "valid_pbmc": "https://www.dropbox.com/s/nqi971n0tk4nbfj/valid_pbmc.h5ad?dl=1", "train_hpoly": "https://www.dropbox.com/s/7ngt0hv21hl2exn/train_hpoly.h5ad?dl=1", "valid_hpoly": "https://...
2,618
38.089552
96
py
EmbeddedModelFlows
EmbeddedModelFlows-main/train_pcnn.py
import tensorflow_datasets as tfds import tensorflow as tf import pixelcnn_original tfk = tf.keras tfkl = tf.keras.layers image_side_size = 14 # Load MNIST from tensorflow_datasets data = tfds.load("mnist", split=["train", "test"]) train_data, test_data = data[0], data[1] def image_preprocess(x): x['image'] = tf....
1,343
24.846154
85
py
EmbeddedModelFlows
EmbeddedModelFlows-main/generative_timeseries_real.py
import os import shutil import pickle import functools import tensorflow as tf import tensorflow_probability as tfp import surrogate_posteriors import timeseries_datasets import process_stock import numpy as np import matplotlib.pyplot as plt tfd = tfp.distributions tfb = tfp.bijectors tfk = tf.keras tfkl = tfk.layer...
9,889
35.62963
148
py
EmbeddedModelFlows
EmbeddedModelFlows-main/main.py
import tensorflow as tf import tensorflow_probability as tfp import matplotlib.pyplot as plt import surrogate_posteriors from models import get_model from surrogate_posteriors import get_surrogate_posterior from metrics import negative_elbo, forward_kl from tensorflow_probability.python.internal import test_util from...
2,350
37.540984
145
py
EmbeddedModelFlows
EmbeddedModelFlows-main/pixelcnn_surrogate_posterior.py
import random import os import pickle import time import matplotlib.pyplot as plt import tensorflow as tf import tensorflow_probability as tfp from tensorflow_probability.python.internal import prefer_static as ps import pixelcnn_original from metrics import negative_elbo, forward_kl from surrogate_posteriors import ...
7,894
39.076142
178
py
EmbeddedModelFlows
EmbeddedModelFlows-main/generative_mnist.py
import os import shutil import time import pickle import tensorflow_datasets as tfds import tensorflow as tf import tensorflow_probability as tfp import matplotlib.pyplot as plt import numpy as np import surrogate_posteriors import tensorflow_probability.python.internal.prefer_static as ps os.environ["CUDA_VISIBLE_DE...
11,213
33.611111
104
py
EmbeddedModelFlows
EmbeddedModelFlows-main/pixelcnn_original.py
# Copyright 2019 The TensorFlow Probability Authors. # Copyright 2019 OpenAI (http://openai.com). # # 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/LICENS...
44,380
44.895553
103
py
EmbeddedModelFlows
EmbeddedModelFlows-main/generative_toy.py
import tensorflow as tf import tensorflow_probability as tfp from toy_data import generate_2d_data import surrogate_posteriors from plot_utils import plot_heatmap_2d import numpy as np import matplotlib.pyplot as plt tfd = tfp.distributions tfb = tfp.bijectors tfk = tf.keras tfkl = tfk.layers Root = tfd.JointDistrib...
3,741
35.686275
146
py
EmbeddedModelFlows
EmbeddedModelFlows-main/generative_hierarchical.py
import os import shutil import pickle import functools import tensorflow as tf import tensorflow_probability as tfp from sklearn import datasets import surrogate_posteriors from tensorflow_probability.python.internal import prefer_static as ps import time import numpy as np import matplotlib.pyplot as plt os.environ[...
10,519
32.717949
114
py
EmbeddedModelFlows
EmbeddedModelFlows-main/timeseries_results.py
import pickle import matplotlib.pyplot as plt import tensorflow as tf import tensorflow_probability as tfp tfd = tfp.distributions tfb = tfp.bijectors tfk = tf.keras tfkl = tfk.layers Root = tfd.JointDistributionCoroutine.Root @tfd.JointDistributionCoroutine def lorenz_system(): truth = [] innovation_noise = .1 ...
4,056
28.18705
84
py
EmbeddedModelFlows
EmbeddedModelFlows-main/flows_bijectors.py
import tensorflow as tf import tensorflow_probability as tfp import numpy as np from tensorflow_probability.python.internal import prefer_static as ps from tensorflow_probability.python.internal import dtype_util tfb = tfp.bijectors tfd = tfp.distributions tfk = tf.keras tfkl = tfk.layers class ActivationNormalizat...
22,921
42.660952
142
py
EmbeddedModelFlows
EmbeddedModelFlows-main/generative_toy_experiments.py
import os import shutil import pickle import functools import tensorflow as tf import tensorflow_probability as tfp from tensorflow_probability.python.internal import prefer_static as ps import time from toy_data import generate_2d_data import surrogate_posteriors from plot_utils import plot_heatmap_2d, plot_samples ...
10,336
34.279863
111
py
EmbeddedModelFlows
EmbeddedModelFlows-main/density_plots.py
import os import shutil import pickle import functools import tensorflow as tf import tensorflow_probability as tfp from toy_data import generate_2d_data import surrogate_posteriors from plot_utils import plot_heatmap_2d, plot_samples import numpy as np import matplotlib.pyplot as plt tfd = tfp.distributions tfb = t...
8,299
32.877551
130
py
EmbeddedModelFlows
EmbeddedModelFlows-main/generative_timeseries_toy.py
import os import shutil import time import pickle import functools import tensorflow as tf import tensorflow_probability as tfp import surrogate_posteriors from tensorflow_probability.python.internal import prefer_static as ps from toy_data import generate_2d_data import surrogate_posteriors from plot_utils import plo...
13,915
35.051813
110
py
EmbeddedModelFlows
EmbeddedModelFlows-main/amortized_posteriors.py
import tensorflow as tf import tensorflow_probability as tfp import tensorflow.keras as tfk import matplotlib.pyplot as plt from surrogate_posteriors import get_surrogate_posterior tfkl = tfk.layers tfd = tfp.distributions tfb = tfp.bijectors tfe = tfp.experimental Root = tfd.JointDistributionCoroutine.Root is_bridge...
3,562
30.8125
112
py
random-walk-embedding
random-walk-embedding-master/src/sampling.py
import networkx as nx import numpy as np import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import os import time from node2vec import Node2Vec from torch.optim.lr_scheduler import ReduceLROnPlateau import sys import multiprocessing from mu...
25,549
32.355091
165
py
TuckER
TuckER-master/main.py
from load_data import Data import numpy as np import torch import time from collections import defaultdict from model import * from torch.optim.lr_scheduler import ExponentialLR import argparse class Experiment: def __init__(self, learning_rate=0.0005, ent_vec_dim=200, rel_vec_dim=200, num_...
8,486
41.014851
115
py
TuckER
TuckER-master/model.py
import numpy as np import torch from torch.nn.init import xavier_normal_ class TuckER(torch.nn.Module): def __init__(self, d, d1, d2, **kwargs): super(TuckER, self).__init__() self.E = torch.nn.Embedding(len(d.entities), d1) self.R = torch.nn.Embedding(len(d.relations), d2) self.W...
1,541
31.808511
90
py
PT4AL
PT4AL-main/main.py
'''Train CIFAR10 with PyTorch.''' import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import torch.backends.cudnn as cudnn import torchvision import torchvision.transforms as transforms import os import argparse import random import numpy as np from models import * from loa...
8,473
33.447154
104
py
PT4AL
PT4AL-main/main_pt4al.py
import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import torch.backends.cudnn as cudnn from torch.utils.data.sampler import SubsetRandomSampler import torchvision import torchvision.transforms as transforms import os import argparse import random from models import * from...
4,280
30.248175
96
py
PT4AL
PT4AL-main/main_random.py
# cold start ex import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import torch.backends.cudnn as cudnn from torch.utils.data.sampler import SubsetRandomSampler import torchvision import torchvision.transforms as transforms import os import argparse import random from mode...
4,384
29.880282
124
py
PT4AL
PT4AL-main/utils.py
'''Some helper functions for PyTorch, including: - get_mean_and_std: calculate the mean and std value of dataset. - msr_init: net parameter initialization. - progress_bar: progress bar mimic xlua.progress. ''' import os import sys import time import math import torch.nn as nn import torch.nn.init as init ...
3,446
26.576
96
py
PT4AL
PT4AL-main/make_data.py
import torch import torchvision from PIL import Image import os class save_dataset(torch.utils.data.Dataset): def __init__(self, dataset, split='train'): self.dataset = dataset self.split = split def __getitem__(self, i): x, y = self.dataset[i] path = './DATA/'+self.split+'/'+str(y)+'/'+str(...
1,165
23.291667
97
py
PT4AL
PT4AL-main/rotation.py
'''Train CIFAR10 with PyTorch.''' import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import torch.backends.cudnn as cudnn import torchvision import torchvision.transforms as transforms import os import argparse import random from models import * from loader import Loader, ...
5,782
34.697531
131
py
PT4AL
PT4AL-main/make_batches.py
'''Train CIFAR10 with PyTorch.''' import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import torch.backends.cudnn as cudnn import torchvision import torchvision.transforms as transforms import os import argparse import random import numpy as np from models import * from loa...
3,537
31.163636
131
py
PT4AL
PT4AL-main/loader.py
import glob import os from PIL import Image, ImageFilter from torch.utils.data import Dataset, DataLoader import torch import torchvision.transforms as transforms import numpy as np import random import cv2 class RotationLoader(Dataset): def __init__(self, is_train=True, transform=None, path='./DATA'): se...
4,257
33.064
173
py
PT4AL
PT4AL-main/models/dla.py
'''DLA in PyTorch. Reference: Deep Layer Aggregation. https://arxiv.org/abs/1707.06484 ''' import torch import torch.nn as nn import torch.nn.functional as F class BasicBlock(nn.Module): expansion = 1 def __init__(self, in_planes, planes, stride=1): super(BasicBlock, self).__init__() sel...
4,425
31.544118
83
py
PT4AL
PT4AL-main/models/shufflenetv2.py
'''ShuffleNetV2 in PyTorch. See the paper "ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" for more details. ''' import torch import torch.nn as nn import torch.nn.functional as F class ShuffleBlock(nn.Module): def __init__(self, groups=2): super(ShuffleBlock, self).__init__() ...
5,530
32.932515
107
py
PT4AL
PT4AL-main/models/regnet.py
'''RegNet in PyTorch. Paper: "Designing Network Design Spaces". Reference: https://github.com/keras-team/keras-applications/blob/master/keras_applications/efficientnet.py ''' import torch import torch.nn as nn import torch.nn.functional as F class SE(nn.Module): '''Squeeze-and-Excitation block.''' def __in...
4,548
28.160256
106
py
PT4AL
PT4AL-main/models/efficientnet.py
'''EfficientNet in PyTorch. Paper: "EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks". Reference: https://github.com/keras-team/keras-applications/blob/master/keras_applications/efficientnet.py ''' import torch import torch.nn as nn import torch.nn.functional as F def swish(x): return x ...
5,719
31.5
106
py
PT4AL
PT4AL-main/models/pnasnet.py
'''PNASNet in PyTorch. Paper: Progressive Neural Architecture Search ''' import torch import torch.nn as nn import torch.nn.functional as F class SepConv(nn.Module): '''Separable Convolution.''' def __init__(self, in_planes, out_planes, kernel_size, stride): super(SepConv, self).__init__() se...
4,258
32.801587
105
py
PT4AL
PT4AL-main/models/resnet.py
'''ResNet in PyTorch. For Pre-activation ResNet, see 'preact_resnet.py'. Reference: [1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun Deep Residual Learning for Image Recognition. arXiv:1512.03385 ''' import torch import torch.nn as nn import torch.nn.functional as F class BasicBlock(nn.Module): expansi...
4,218
30.721805
83
py
PT4AL
PT4AL-main/models/dla_simple.py
'''Simplified version of DLA in PyTorch. Note this implementation is not identical to the original paper version. But it seems works fine. See dla.py for the original paper version. Reference: Deep Layer Aggregation. https://arxiv.org/abs/1707.06484 ''' import torch import torch.nn as nn import torch.nn.function...
4,084
30.666667
83
py
PT4AL
PT4AL-main/models/mobilenetv2.py
'''MobileNetV2 in PyTorch. See the paper "Inverted Residuals and Linear Bottlenecks: Mobile Networks for Classification, Detection and Segmentation" for more details. ''' import torch import torch.nn as nn import torch.nn.functional as F class Block(nn.Module): '''expand + depthwise + pointwise''' def __init...
3,092
34.551724
114
py
PT4AL
PT4AL-main/models/vgg.py
'''VGG11/13/16/19 in Pytorch.''' import torch import torch.nn as nn cfg = { 'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'VGG16': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512...
1,442
29.0625
117
py
PT4AL
PT4AL-main/models/densenet.py
'''DenseNet in PyTorch.''' import math import torch import torch.nn as nn import torch.nn.functional as F class Bottleneck(nn.Module): def __init__(self, in_planes, growth_rate): super(Bottleneck, self).__init__() self.bn1 = nn.BatchNorm2d(in_planes) self.conv1 = nn.Conv2d(in_planes, 4*gr...
3,542
31.805556
96
py
PT4AL
PT4AL-main/models/preact_resnet.py
'''Pre-activation ResNet in PyTorch. Reference: [1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun Identity Mappings in Deep Residual Networks. arXiv:1603.05027 ''' import torch import torch.nn as nn import torch.nn.functional as F class PreActBlock(nn.Module): '''Pre-activation version of the BasicBlock....
4,078
33.277311
102
py
PT4AL
PT4AL-main/models/googlenet.py
'''GoogLeNet with PyTorch.''' import torch import torch.nn as nn import torch.nn.functional as F class Inception(nn.Module): def __init__(self, in_planes, n1x1, n3x3red, n3x3, n5x5red, n5x5, pool_planes): super(Inception, self).__init__() # 1x1 conv branch self.b1 = nn.Sequential( ...
3,221
28.833333
83
py
PT4AL
PT4AL-main/models/resnext.py
'''ResNeXt in PyTorch. See the paper "Aggregated Residual Transformations for Deep Neural Networks" for more details. ''' import torch import torch.nn as nn import torch.nn.functional as F class Block(nn.Module): '''Grouped convolution block.''' expansion = 2 def __init__(self, in_planes, cardinality=32...
3,478
35.239583
129
py
PT4AL
PT4AL-main/models/senet.py
'''SENet in PyTorch. SENet is the winner of ImageNet-2017. The paper is not released yet. ''' import torch import torch.nn as nn import torch.nn.functional as F class BasicBlock(nn.Module): def __init__(self, in_planes, planes, stride=1): super(BasicBlock, self).__init__() self.conv1 = nn.Conv2d(...
4,027
32.016393
102
py
PT4AL
PT4AL-main/models/shufflenet.py
'''ShuffleNet in PyTorch. See the paper "ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices" for more details. ''' import torch import torch.nn as nn import torch.nn.functional as F class ShuffleBlock(nn.Module): def __init__(self, groups): super(ShuffleBlock, self).__init...
3,542
31.209091
126
py
PT4AL
PT4AL-main/models/lenet.py
'''LeNet in PyTorch.''' import torch.nn as nn import torch.nn.functional as F class LeNet(nn.Module): def __init__(self): super(LeNet, self).__init__() self.conv1 = nn.Conv2d(3, 6, 5) self.conv2 = nn.Conv2d(6, 16, 5) self.fc1 = nn.Linear(16*5*5, 120) self.fc2 = nn.Linear...
699
28.166667
43
py
PT4AL
PT4AL-main/models/mobilenet.py
'''MobileNet in PyTorch. See the paper "MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications" for more details. ''' import torch import torch.nn as nn import torch.nn.functional as F class Block(nn.Module): '''Depthwise conv + Pointwise conv''' def __init__(self, in_planes, out_...
2,025
31.677419
123
py
PT4AL
PT4AL-main/models/dpn.py
'''Dual Path Networks in PyTorch.''' import torch import torch.nn as nn import torch.nn.functional as F class Bottleneck(nn.Module): def __init__(self, last_planes, in_planes, out_planes, dense_depth, stride, first_layer): super(Bottleneck, self).__init__() self.out_planes = out_planes sel...
3,562
34.989899
116
py
deepcluster
deepcluster-main/main.py
# Copyright (c) 2017-present, Facebook, Inc. # 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 pickle import time import faiss import numpy as np from sklearn.metrics.cluster import normali...
12,276
36.429878
94
py
deepcluster
deepcluster-main/eval_linear.py
# Copyright (c) 2017-present, Facebook, Inc. # 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 import numpy as np import torch import torch.nn as nn import torch.backends.cudnn as cud...
11,427
34.7125
117
py
deepcluster
deepcluster-main/eval_retrieval.py
# Copyright (c) 2017-present, Facebook, Inc. # 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 collections import OrderedDict import os import pickle import subprocess import sys import numpy as np f...
19,227
38.892116
118
py
deepcluster
deepcluster-main/clustering.py
# Copyright (c) 2017-present, Facebook, Inc. # 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 time import faiss import numpy as np from PIL import Image from PIL import ImageFile from scipy.sparse import csr_matrix...
11,730
29.952507
93
py
deepcluster
deepcluster-main/util.py
# Copyright (c) 2017-present, Facebook, Inc. # 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 os import pickle import numpy as np import torch from torch.utils.data.sampler import Sampler import models def load_...
3,788
27.488722
85
py
deepcluster
deepcluster-main/eval_voc_classif.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python # -*- coding: utf-8 -*- import argparse import os import math import time import glob from collections im...
10,520
34.785714
138
py
deepcluster
deepcluster-main/visu/gradient_ascent.py
# Copyright (c) 2017-present, Facebook, Inc. # 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 from scipy.ndimage.filters import gaussian_filter import sys import numpy as np from PIL import Image...
4,670
32.364286
109
py
deepcluster
deepcluster-main/visu/activ-retrieval.py
# Copyright (c) 2017-present, Facebook, Inc. # 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 from shutil import copyfile import sys import numpy as np from PIL import Image import torch import t...
3,875
32.704348
92
py
deepcluster
deepcluster-main/models/vgg16.py
# Copyright (c) 2017-present, Facebook, Inc. # 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 import math from random import random as rd __all__ = [ 'VGG', 'vgg16'] class VGG(nn.Modul...
3,191
32.6
98
py
deepcluster
deepcluster-main/models/alexnet.py
# Copyright (c) 2017-present, Facebook, Inc. # 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 math import numpy as np import torch import torch.nn as nn __all__ = [ 'AlexNet', 'alexnet'] # (number of filters, ke...
3,409
33.444444
107
py
anime2clothing
anime2clothing-master/test.py
from __future__ import print_function import argparse import os from PIL import Image import torch import torchvision.transforms as transforms import torchvision.utils as vutils from generator.unet.unet_model import UNet # Testing settings parser = argparse.ArgumentParser(description='pix2pix-pytorch-implementatio...
1,643
29.444444
89
py
anime2clothing
anime2clothing-master/dataset.py
import os from os import listdir from os.path import join import random import numpy as np from PIL import Image, ImageFile, ImageOps, ImageDraw, ImageFilter ImageFile.LOAD_TRUNCATED_IMAGES = True import torch.utils.data as data import torchvision.transforms as transforms import torchvision.transforms.functional as F ...
5,109
36.851852
116
py
anime2clothing
anime2clothing-master/pix2pix_pro.py
import torch from generator.networks import define_G, define_D from discriminator.discriminator_model import PG_MultiScaleDiscriminator, PG_MultiPatchDiscriminator from generator.networks import GANLoss, get_scheduler, update_learning_rate from generator.base_model import BaseModel class Pix2PixPro(BaseModel): de...
6,288
45.242647
118
py
anime2clothing
anime2clothing-master/train.py
from __future__ import print_function import os from math import log10 from collections import OrderedDict import torchvision.utils as vutils import torch import torch.nn as nn import torch.nn.functional as f from torch.utils.data import DataLoader from dataset import DatasetFromFolder import torch.backends.cudnn as...
7,013
40.017544
151
py
anime2clothing
anime2clothing-master/options/base_options.py
import argparse import os from util import util import torch class BaseOptions(): def __init__(self): self.parser = argparse.ArgumentParser() self.initialized = False def initialize(self): # experiment specifics self.parser.add_argument('--project_name', type=str, default='...
6,925
66.901961
228
py
anime2clothing
anime2clothing-master/discriminator/discriminator_parts.py
import torch import torch.nn as nn from torch.nn.init import kaiming_normal_, calculate_gain import torch.nn.functional as F class double_conv(nn.Module): '''(conv => BN => ReLU) * 2''' def __init__(self, in_ch, out_ch): super(double_conv, self).__init__() self.conv = nn.Sequential( ...
6,887
38.136364
120
py
anime2clothing
anime2clothing-master/discriminator/discriminator_model.py
import torch import torch.nn as nn from .discriminator_parts import * import numpy as np class ImageGAN(nn.Module): def __init__(self, n_channels, n_classes): super(ImageGAN, self).__init__() self.inc = inconv(n_channels, 64) self.down1 = down(64, 128) self.down2 = down(128, 256) ...
22,373
42.360465
263
py
anime2clothing
anime2clothing-master/util/image_pool.py
import random import torch from torch.autograd import Variable class ImagePool(): def __init__(self, pool_size): self.pool_size = pool_size if self.pool_size > 0: self.num_imgs = 0 self.images = [] def query(self, images): if self.pool_size == 0: retu...
1,090
33.09375
67
py
anime2clothing
anime2clothing-master/util/util.py
from __future__ import print_function import torch import numpy as np from PIL import Image import numpy as np import os # Converts a Tensor into a Numpy array # |imtype|: the desired type of the converted numpy array def tensor2im(image_tensor, imtype=np.uint8, normalize=True): if isinstance(image_tensor, list): ...
4,873
37.992
129
py
anime2clothing
anime2clothing-master/generator/base_model.py
import os import torch import sys class BaseModel(torch.nn.Module): def name(self): return 'BaseModel' def initialize(self, opt): self.opt = opt self.gpu_ids = opt.gpu_ids self.isTrain = opt.isTrain self.Tensor = torch.cuda.FloatTensor if self.gpu_ids else torch.Tensor ...
3,571
36.208333
126
py
anime2clothing
anime2clothing-master/generator/networks.py
import torch import torch.nn as nn from torch.nn import init import functools from torch.optim import lr_scheduler from torch.nn.init import kaiming_normal_, calculate_gain from torch.autograd import Variable import torch.autograd as autograd import numpy as np from generator.unet.unet_model import UNet from generator....
30,523
40.472826
181
py
anime2clothing
anime2clothing-master/generator/unet/unet_model.py
# full assembly of the sub-parts to form the complete net import torch.nn.functional as F import numpy as np from .unet_parts import * class UNet(nn.Module): def __init__(self, n_channels, n_classes, use_dropout=False, norm_type="batch",conv_type="equal", is_acgan=False, is_msg=False, is_self_attn=False, ...
17,514
50.973294
204
py
anime2clothing
anime2clothing-master/generator/unet/unet_parts.py
# sub-parts of the U-Net model import torch import torch.nn as nn import torch.nn.functional as F import functools from torch.nn.init import kaiming_normal_, calculate_gain ################################################################################# # Construct Help Functions Class###############################...
22,746
36.047231
191
py
anime2clothing
anime2clothing-master/generator/resnet/resnet_model.py
import torch.nn as nn import functools import torch # Defines the generator that consists of Resnet blocks between a few # downsampling/upsampling operations. class ResnetGenerator(nn.Module): def __init__(self, input_nc, output_nc, ngf=64, norm_layer=nn.BatchNorm2d, use_dropout=False, n_blocks=9, padding_type='re...
11,539
33.969697
134
py
DepTriggerNER
DepTriggerNER-master/util.py
import torch from collections import defaultdict def remove_duplicates(features, labels, triggers, dataset): feature_dict = defaultdict(list) for feature, label, trigger in zip(features, labels, triggers): feature_dict[trigger].append((feature, label)) for key, value in feature_dict.items(): ...
1,245
30.15
67
py
DepTriggerNER
DepTriggerNER-master/config/utils.py
from typing import List from common import Instance import torch.optim as optim import pickle import os.path from config import PAD, ContextEmb, Config import torch import torch.nn as nn def log_sum_exp_pytorch(vec: torch.Tensor) -> torch.Tensor: """ Calculate the log_sum_exp trick for the tensor. :param ...
7,753
45.154762
181
py
DepTriggerNER
DepTriggerNER-master/config/config.py
import numpy as np from tqdm import tqdm from typing import List, Tuple, Dict, Union from common import Instance import torch from enum import Enum import os START = "<START>" STOP = "<STOP>" PAD = "<PAD>" UNK = "<UNK>" class ContextEmb(Enum): none = 0 elmo = 1 bert = 2 # not support yet flair = 3 # n...
10,820
39.52809
135
py
DepTriggerNER
DepTriggerNER-master/config/eval.py
import numpy as np from typing import List from common import Instance import torch class Span: """ A class of `Span` where we use it during evaluation. We construct spans for the convenience of evaluation. """ def __init__(self, left: int, right: int, type: str): """ A span compose...
3,336
39.695122
140
py
DepTriggerNER
DepTriggerNER-master/config/__init__.py
from config.config import Config, ContextEmb, PAD, START, STOP from config.eval import Span, evaluate_batch_insts from config.reader import Reader from config.utils import log_sum_exp_pytorch, simple_batching, lr_decay, get_optimizer,\ write_results, batching_list_instances
280
45.833333
89
py
DepTriggerNER
DepTriggerNER-master/model/trigger_encoder.py
from config import ContextEmb, batching_list_instances from config.utils import get_optimizer import torch import torch.nn as nn import torch.nn.functional as F from model.attention import Attention from sklearn.metrics import accuracy_score from tqdm import tqdm from collections import defaultdict class ContrastiveL...
8,709
47.388889
121
py
DepTriggerNER
DepTriggerNER-master/model/base_encoder.py
from model.charbilstm import CharBiLSTM from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence import torch.nn as nn import torch class Encoder(nn.Module): def __init__(self, config): super(Encoder, self).__init__() self.config = config self.device = config.device ...
3,865
43.953488
136
py
DepTriggerNER
DepTriggerNER-master/model/charbilstm.py
import torch import torch.nn as nn from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence class CharBiLSTM(nn.Module): def __init__(self, config, print_info: bool = True): super(CharBiLSTM, self).__init__() if print_info: print("[Info] Building character-level LSTM"...
2,258
44.18
191
py
DepTriggerNER
DepTriggerNER-master/model/ner_encoder.py
from config import ContextEmb, batching_list_instances from config.eval import evaluate_batch_insts from config.utils import get_optimizer from model.linear_crf_inferencer import LinearCRF import torch import torch.nn as nn import torch.nn.functional as F from tqdm import tqdm import numpy as np from model.base_encoder...
10,817
46.656388
119
py
DepTriggerNER
DepTriggerNER-master/model/attention.py
import torch import torch.nn as nn import random class Attention(nn.Module): def __init__(self, config): super(Attention, self).__init__() self.config = config self.device = config.device self.linear = nn.Linear(config.hidden_dim, config.hidden_dim // 2).to(self.device) se...
3,069
47.730159
119
py
DepTriggerNER
DepTriggerNER-master/model/linear_crf_inferencer.py
import torch.nn as nn import torch from config import log_sum_exp_pytorch, START, STOP, PAD from typing import Tuple class LinearCRF(nn.Module): def __init__(self, config, print_info: bool = True): super(LinearCRF, self).__init__() self.label_size = config.label_size self.device = confi...
9,316
56.159509
241
py
DDAD
DDAD-master/evaluation/semantic_evaluation.py
# Copyright 2021 Toyota Research Institute. All rights reserved. import argparse import os from argparse import Namespace from collections import OrderedDict from glob import glob import cv2 import matplotlib.pyplot as plt import numpy as np import torch from tqdm import tqdm ddad_to_cityscapes = { # ROAD 7...
16,870
35.203863
127
py
fast_sw
fast_sw-main/synthetic_exp/main.py
import numpy as np import os import torch import itertools import pickle5 as pickle from time import time from scipy.stats import linregress import matplotlib import matplotlib.pyplot as plt plt.style.use('seaborn-colorblind') matplotlib.rcParams.update({'font.size': 16}) np.random.seed(10) def montecarlo_sw(X, Y, L...
17,388
43.473146
139
py
fast_sw
fast_sw-main/swg/utils.py
import torch def wasserstein1d(x, y): x1, _ = torch.sort(x, dim=0) y1, _ = torch.sort(y, dim=0) z = (x1-y1).view(-1) n, l = x.size() return torch.dot(z, z) / (n*l) def clt_sw(x, y): n, dim = x.shape meanx = torch.mean(x, dim=0) xc = x - meanx gamma_xc = torch.mean(torch.lina...
1,718
22.22973
66
py
fast_sw
fast_sw-main/swg/disc.py
import torch.nn as nn class DiscriminatorCONV_MNIST(nn.Module): def __init__(self, x_dim, f_dim): super(DiscriminatorCONV_MNIST, self).__init__() self.l1 = nn.Sequential( nn.Linear(x_dim, f_dim), nn.ReLU(True)) self.l2 = nn.Sequential( ...
1,910
30.85
63
py
fast_sw
fast_sw-main/swg/gen.py
import torch.nn as nn class GeneratorCONV_MNIST(nn.Module): def __init__(self, nz): super(GeneratorCONV_MNIST, self).__init__() self.l1 = nn.Linear(nz, 1024) self.network = nn.Sequential( nn.ConvTranspose2d(1024, 64, 3, 2, bias=False), nn.BatchNorm2d(64), ...
3,934
30.99187
80
py
fast_sw
fast_sw-main/swg/noise_creator.py
import torch from torch.distributions.multivariate_normal import MultivariateNormal class NoiseCreator: def __init__(self, latent_size: int): self.__distribution = MultivariateNormal(torch.zeros(latent_size), torch.eye(latent_size)) def create(self, batch_size: int) -> torch.Tensor: return ...
361
26.846154
98
py
fast_sw
fast_sw-main/swg/train.py
# Some files in this project were adapted from the following open source implementations: # 1) https://github.com/ishansd/swg # 2) https://github.com/maremun/swg # 3) https://github.com/gmum/cwae-pytorch import numpy as np import csv import os import matplotlib.pyplot as plt from time import time import torch import ...
9,018
36.268595
139
py
fast_sw
fast_sw-main/swg/precalc_fid.py
import argparse import torch import numpy as np from externals.inception import InceptionV3 from factories.dataset_factory import get_dataset from externals.fid_score import get_predictions_for_batch, calculate_statistics_for_activations def get_activations_for_dataloader(model: InceptionV3, dataloader: torch.utils.d...
2,954
35.036585
139
py
fast_sw
fast_sw-main/swg/factories/dataset_factory.py
from torchvision import transforms from torchvision.datasets import MNIST, CelebA def get_dataset(identifier: str, dataroot: str, train: bool): resolvers = { 'mnist': get_mnist_dataset, 'celeba': get_celeba_dataset } return resolvers[identifier](dataroot, train) def get_mnist_dataset(dat...
967
27.470588
61
py
fast_sw
fast_sw-main/swg/evaluators/fid_evaluator.py
import torch import torch.nn from externals.inception import InceptionV3 from externals.fid_score import calculate_activation_statistics, calculate_frechet_distance from noise_creator import NoiseCreator from tqdm import tqdm class FidComputer: def __init__(self, inception_model: InceptionV3, precomputed_stats: ...
2,125
43.291667
108
py
fast_sw
fast_sw-main/swg/externals/inception.py
""" Code copied from: https://github.com/mseitzer/pytorch-fid/blob/master/inception.py Licensed under the Apache License, Version 2.0: https://github.com/mseitzer/pytorch-fid/blob/master/LICENSE; Copyright https://github.com/mseitzer """ import torch import torch.nn as nn import torch.nn.functional as F import torchvi...
12,421
35.643068
126
py
fast_sw
fast_sw-main/swg/externals/fid_score.py
""" Code adapted from: https://github.com/mseitzer/pytorch-fid/blob/master/fid_score.py Licensed under the Apache License, Version 2.0: https://github.com/mseitzer/pytorch-fid/blob/master/LICENSE; Copyright https://github.com/mseitzer to use tensors instead of file paths Calculates the Frechet Inception Distance (FID...
6,409
38.813665
108
py
lofar-vlbi
lofar-vlbi-master/plugins/PipelineStep_DownloadCats.py
#!/usr/bin/env python import os, sys, logging, io import numpy as np import pyvo as vo import pyrap.tables as pt from astropy.table import Table, Column, vstack, unique, hstack import argparse from lofarpipe.support.data_map import DataMap from lofarpipe.support.data_map import DataProduct import requests from astropy....
21,904
39.943925
453
py
OpenWPM
OpenWPM-master/test/test_http_instrumentation.py
#!/usr/bin/python # -*- coding: utf-8 -*- import base64 import json import os from hashlib import sha256 from pathlib import Path from time import sleep from typing import List, Optional, Set, Tuple from urllib.parse import urlparse import pytest from openwpm import command_sequence, task_manager from openwpm.comman...
38,598
33.617937
156
py
HPOBench
HPOBench-master/examples/container/xgboost_with_container.py
""" Example with XGBoost (container) ================================ In this example, we show how to use a benchmark with a container. We provide container for some benchmarks. They are hosted on https://cloud.sylabs.io/library/muelleph/automl. Furthermore, we use different fidelities to train the xgboost model - th...
3,296
41.269231
119
py
HPOBench
HPOBench-master/examples/local/xgboost_local.py
""" Example with XGBoost (local) ============================ This example executes the xgboost benchmark locally with random configurations on the CC18 openml tasks. To run this example please install the necessary dependencies via: ``pip3 install .[xgboost_example]`` """ import argparse from time import time from ...
2,623
40.650794
119
py