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 |
|---|---|---|---|---|---|---|
GANFingerprints | GANFingerprints-master/classifier_visNet/nets/mobilenet/mobilenet_v2.py | # Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 8,078 | 36.230415 | 80 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/nets/mobilenet/conv_blocks.py | # Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 13,146 | 35.62117 | 80 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/nets/mobilenet/mobilenet_v2_test.py | # Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 7,083 | 36.284211 | 80 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/nets/mobilenet/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/classifier_visNet/nets/mobilenet/mobilenet.py | # Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 17,332 | 36.036325 | 80 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/metrics/sliced_wasserstein.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 5,977 | 41.397163 | 135 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/metrics/frechet_inception_distance.py | #!/usr/bin/env python3
#
# Copyright 2017 Martin Heusel
#
# 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 la... | 11,441 | 39.574468 | 110 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/metrics/ms_ssim.py | #!/usr/bin/python
#
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | 8,160 | 39.60199 | 128 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/metrics/inception_score.py | # Copyright 2016 Wojciech Zaremba
#
# 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 or agreed to in writ... | 5,305 | 34.851351 | 110 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/metrics/__init__.py | # empty
| 8 | 3.5 | 7 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/tensorflow_vgg/vgg19_trainable.py | import tensorflow as tf
import numpy as np
from functools import reduce
VGG_MEAN = [103.939, 116.779, 123.68]
class Vgg19:
"""
A trainable version VGG19.
"""
def __init__(self, vgg19_npy_path=None, trainable=True, dropout=0.5):
if vgg19_npy_path is not None:
self.data_dict = np.... | 6,685 | 37.647399 | 113 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/tensorflow_vgg/test_vgg19.py | import numpy as np
import tensorflow as tf
import vgg19
import utils
img1 = utils.load_image("./test_data/tiger.jpeg")
img2 = utils.load_image("./test_data/puzzle.jpeg")
batch1 = img1.reshape((1, 224, 224, 3))
batch2 = img2.reshape((1, 224, 224, 3))
batch = np.concatenate((batch1, batch2), 0)
# with tf.Session(con... | 845 | 28.172414 | 115 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/tensorflow_vgg/vgg16.py | import inspect
import os
import numpy as np
import tensorflow as tf
import time
VGG_MEAN = [103.939, 116.779, 123.68]
class Vgg16:
def __init__(self, vgg16_npy_path=None):
if vgg16_npy_path is None:
path = inspect.getfile(Vgg16)
path = os.path.abspath(os.path.join(path, os.pardir... | 4,414 | 34.039683 | 106 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/tensorflow_vgg/utils.py | import skimage
import skimage.io
import skimage.transform
import numpy as np
# synset = [l.strip() for l in open('synset.txt').readlines()]
# returns image of shape [224, 224, 3]
# [height, width, depth]
def load_image(path):
# load image
img = skimage.io.imread(path)
img = img / 255.0
assert (0 <= ... | 1,921 | 25.328767 | 64 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/tensorflow_vgg/vgg19.py | import os
import tensorflow as tf
import numpy as np
import time
import inspect
VGG_MEAN = [103.939, 116.779, 123.68]
class Vgg19:
def __init__(self, vgg19_npy_path=None):
if vgg19_npy_path is None:
path = inspect.getfile(Vgg19)
path = os.path.abspath(os.path.join(path, os.pardir... | 4,616 | 34.790698 | 106 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/tensorflow_vgg/test_vgg19_trainable.py | """
Simple tester for the vgg19_trainable
"""
import tensorflow as tf
import vgg19_trainable as vgg19
import utils
img1 = utils.load_image("./test_data/tiger.jpeg")
img1_true_result = [1 if i == 292 else 0 for i in range(1000)] # 1-hot result for tiger
batch1 = img1.reshape((1, 224, 224, 3))
with tf.device('/cpu:... | 1,397 | 30.066667 | 95 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/tensorflow_vgg/test_vgg16.py | import numpy as np
import tensorflow as tf
import vgg16
import utils
img1 = utils.load_image("./test_data/tiger.jpeg")
img2 = utils.load_image("./test_data/puzzle.jpeg")
batch1 = img1.reshape((1, 224, 224, 3))
batch2 = img2.reshape((1, 224, 224, 3))
batch = np.concatenate((batch1, batch2), 0)
# with tf.Session(con... | 845 | 28.172414 | 115 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/tensorflow_vgg/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/main.py | import sys
import numpy as np
import core
from utils.misc import pp, visualize
import tensorflow as tf
flags = tf.app.flags
flags.DEFINE_integer("max_iteration", 150000, "Epoch to train [150000]")
flags.DEFINE_float("learning_rate", .0001, "Learning rate [.0001]")
flags.DEFINE_float("learning_rate_D", -1, "Learning r... | 7,225 | 53.330827 | 191 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/compute_scores.py | from __future__ import division, print_function
import os.path, sys, tarfile
import numpy as np
from scipy import linalg
from six.moves import range, urllib
from sklearn.metrics.pairwise import polynomial_kernel
import tensorflow as tf
from tqdm import tqdm
# from tqdm docs: https://pypi.python.org/pypi/tqdm#hooks-a... | 18,512 | 35.087719 | 119 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/summarize.py | import argparse
import os
import numpy as np
parser = argparse.ArgumentParser()
parser.add_argument('files', nargs='+')
parser.add_argument('--tex', action='store_true')
args = parser.parse_args()
if args.tex:
split = ' & '
end = '\\\\\n'
else:
split = ' '
end = '\n'
print(' ' * 79 + 'Inceptio... | 1,506 | 30.395833 | 77 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/architecture.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 10 14:34:47 2018
@author: mikolajbinkowski
"""
import tensorflow as tf
from core.ops import batch_norm, conv2d, deconv2d, linear, lrelu
from utils.misc import conv_sizes
# Generators
class Generator:
def __init__(self, dim, c_dim, output_size, ... | 9,781 | 42.475556 | 115 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/cramer.py | from .model import MMD_GAN, tf, np
from .architecture import get_networks
from .ops import safer_norm
class Cramer_GAN(MMD_GAN):
def build_model(self):
self.global_step = tf.Variable(0, name="global_step", trainable=False)
self.lr = tf.Variable(self.config.learning_rate, name='lr... | 4,955 | 50.625 | 116 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/mmd.py | '''
MMD functions implemented in tensorflow.
'''
from __future__ import division
_eps=1.0e-5
import tensorflow as tf
import numpy as np
from .ops import dot, sq_sum
mysqrt = lambda x: tf.sqrt(tf.maximum(x + _eps, 0.))
def _distance_kernel(X, Y, K_XY_only=False):
XX = tf.matmul(X, X, transpose_b=True)
XY = t... | 17,404 | 33.465347 | 102 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/model.py | from __future__ import division, print_function
import os, sys, time, pprint, numpy as np
from . import mmd
from .ops import safer_norm, tf
from .architecture import get_networks
from .pipeline import get_pipeline
from utils import timer, scorer, misc
class MMD_GAN(object):
def __init__(self, sess, config,
... | 21,413 | 44.464968 | 133 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/wgan_gp.py | from .model import MMD_GAN, tf
class WGAN_GP(MMD_GAN):
def __init__(self, sess, config, **kwargs):
config.dof_dim = 1
super(WGAN_GP, self).__init__(sess, config, **kwargs)
def set_loss(self, G, images):
alpha = tf.random_uniform(shape=[self.batch_size, 1, 1, 1])
real_d... | 1,240 | 41.793103 | 93 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/__init__.py | __all__= ['model', 'wgan_gp', 'cramer', 'ops', 'mmd', 'resnet', 'architecture']
| 80 | 39.5 | 79 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/ops.py | from tensorflow.python.framework import ops
from utils.misc import variable_summaries
from .mmd import _eps, tf
class batch_norm(object):
def __init__(self, epsilon=1e-5, momentum = 0.9, name="batch_norm"):
with tf.variable_scope(name):
self.epsilon = epsilon
self.momentum = momentum
self.nam... | 7,220 | 38.244565 | 104 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/pipeline.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 11 14:11:46 2018
@author: mikolajbinkowski
"""
import os, time, lmdb, io
import numpy as np
import tensorflow as tf
from PIL import Image
from glob import glob
import matplotlib.pyplot as plt
from utils import misc
class Pipeline:
def __init__(... | 11,697 | 39.337931 | 139 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/block.py | """
Based on https://github.com/igul222/improved_wgan_training/blob/master/gan_64x64.py.
"""
import functools
import tensorflow as tf
from core.resnet.ops import conv2d, batchnorm, layernorm
def ResidualBlock(name, input_dim, output_dim, filter_size, inputs, resample=None, he_init=True):
"""
resample: None, '... | 3,394 | 44.266667 | 116 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/__init__.py | import numpy as np
import tensorflow as tf
import locale
locale.setlocale(locale.LC_ALL, '')
__all__ = ['block', 'ops']
_params = {}
_param_aliases = {}
def param(name, *args, **kwargs):
"""
A wrapper for `tf.Variable` which enables parameter sharing in models.
Creates and returns theano shared varia... | 1,889 | 29 | 119 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/ops/conv2d.py | """
Based on https://github.com/igul222/improved_wgan_training/blob/master/
"""
from ... import resnet as lib
import numpy as np
import tensorflow as tf
_default_weightnorm = False
def enable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = True
_weights_stdev = None
def set_weights_std... | 3,910 | 30.039683 | 140 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/ops/cond_batchnorm.py | import resnet as lib
import numpy as np
import tensorflow as tf
def Batchnorm(name, axes, inputs, is_training=None, stats_iter=None, update_moving_stats=True, fused=True, labels=None, n_labels=None):
"""conditional batchnorm (dumoulin et al 2016) for BCHW conv filtermaps"""
if axes != [0,2,3]:
raise E... | 871 | 50.294118 | 135 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/ops/batchnorm.py | """
Based on https://github.com/igul222/improved_wgan_training/blob/master/
"""
from ... import resnet as lib
import numpy as np
import tensorflow as tf
def Batchnorm(name, axes, inputs, is_training=None, stats_iter=None, update_moving_stats=True, fused=True):
if ((axes == [0,2,3]) or (axes == [0,2])) and fused==T... | 4,463 | 48.6 | 169 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/ops/deconv2d.py | import resnet as lib
import numpy as np
import tensorflow as tf
_default_weightnorm = False
def enable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = True
_weights_stdev = None
def set_weights_stdev(weights_stdev):
global _weights_stdev
_weights_stdev = weights_stdev
def unse... | 3,277 | 27.258621 | 101 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/ops/layernorm.py | """
Based on https://github.com/igul222/improved_wgan_training/blob/master/
"""
from ... import resnet as lib
import numpy as np
import tensorflow as tf
def Layernorm(name, norm_axes, inputs):
mean, var = tf.nn.moments(inputs, norm_axes, keep_dims=True)
# Assume the 'neurons' axis is the first of norm_axes. T... | 911 | 37 | 117 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/ops/conv1d.py | import tflib as lib
import numpy as np
import tensorflow as tf
_default_weightnorm = False
def enable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = True
def Conv1D(name, input_dim, output_dim, filter_size, inputs, he_init=True, mask_type=None, stride=1, weightnorm=None, biases=True, ... | 3,401 | 30.211009 | 140 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/ops/linear.py | import resnet as lib
import numpy as np
import tensorflow as tf
_default_weightnorm = False
def enable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = True
def disable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = False
_weights_stdev = None
def set_we... | 4,325 | 29.041667 | 98 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/core/resnet/ops/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/utils/timer.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 19 13:42:24 2018
@author: mikolajbinkowski
"""
import time
class Timer(object):
def __init__(self, start_time=time.time(), limit=100):
self.start_time = start_time
self.limit = limit
def __call__(self, step, mess... | 843 | 23.823529 | 69 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/utils/get_test_images.py | import tensorflow as tf
import numpy as np
import os
os.chdir(os.path.join(os.getcwd(), '..', '..'))
import core.pipeline
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--dataset', default='lsun', help='dataset to sample from')
parser.add_argument('--data... | 1,553 | 41 | 115 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/utils/scorer.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 10 17:23:38 2018
@author: mikolajbinkowski
"""
import time, os, scipy, sys
import numpy as np
from core import mmd
import compute_scores as cs
class Scorer(object):
def __init__(self, dataset, lr_scheduler=True, stdout=sys.stdout):
self... | 6,569 | 44.625 | 141 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/utils/misc.py | """
Some codes from https://github.com/Newmu/dcgan_code
Released under the MIT license.
"""
from __future__ import division
import random
import pprint
import scipy.misc
import numpy as np
from time import gmtime, strftime
import tensorflow as tf
from six.moves import xrange
pp = pprint.PrettyPrinter()
def inverse_t... | 9,739 | 33.661922 | 112 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/utils/utils.py | """
Some codes from https://github.com/Newmu/dcgan_code
Released under the MIT license.
"""
from __future__ import division
import random
import pprint
import scipy.misc
import numpy as np
from time import gmtime, strftime
import tensorflow as tf
from six.moves import xrange
pp = pprint.PrettyPrinter()
def inverse_t... | 9,736 | 33.775 | 112 | py |
GANFingerprints | GANFingerprints-master/MMDGAN/gan/utils/__init__.py | __all__ = ['scorer', 'timer', 'misc']
| 38 | 18.5 | 37 | py |
GANFingerprints | GANFingerprints-master/SNGAN/updater.py | import numpy as np
import chainer
import chainer.functions as F
from chainer import Variable
from source.miscs.random_samples import sample_continuous, sample_categorical
# Classic Adversarial Loss
def loss_dcgan_dis(dis_fake, dis_real):
L1 = F.mean(F.softplus(-dis_real))
L2 = F.mean(F.softplus(dis_fake))
... | 3,334 | 32.019802 | 86 | py |
GANFingerprints | GANFingerprints-master/SNGAN/train_mn.py | import os, sys, time
import shutil
import yaml
import argparse
import chainer
from chainer import training
from chainer.training import extension
from chainer.training import extensions
import chainermn
import multiprocessing
sys.path.append(os.path.dirname(__file__))
from evaluation import sample_generate_condition... | 6,592 | 42.662252 | 120 | py |
GANFingerprints | GANFingerprints-master/SNGAN/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/SNGAN/evaluation.py | import os
import sys
import math
import numpy as np
from PIL import Image
import scipy.linalg
import chainer
import chainer.cuda
from chainer import Variable
from chainer import serializers
from chainer import cuda
import chainer.functions as F
sys.path.append(os.path.dirname(__file__))
sys.path.append('../')
from s... | 8,815 | 35.580913 | 114 | py |
GANFingerprints | GANFingerprints-master/SNGAN/train.py | import os, sys, time
import shutil
import yaml
import argparse
import chainer
from chainer import training
from chainer.training import extension
from chainer.training import extensions
sys.path.append(os.path.dirname(__file__))
from evaluation import sample_generate_conditional, sample_generate_light, calc_inceptio... | 5,656 | 42.515385 | 116 | py |
GANFingerprints | GANFingerprints-master/SNGAN/evaluations/calc_intra_FID.py | import os, sys
import numpy as np
import argparse
import chainer
base = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(base, '../'))
from evaluation import gen_images, gen_images_with_condition, load_inception_model
import yaml
import source.yaml_utils as yaml_utils
from evaluation import FID
... | 2,540 | 38.092308 | 102 | py |
GANFingerprints | GANFingerprints-master/SNGAN/evaluations/calc_ref_stats.py | import os, sys
import numpy as np
import argparse
import chainer
base = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(base, '../'))
from evaluation import load_inception_model
import scipy.ndimage as ndimage
from scipy.misc import imresize
IMAGENET_ROOT_PATH = "/path/to/imagenet/train"
IMAG... | 2,532 | 34.180556 | 102 | py |
GANFingerprints | GANFingerprints-master/SNGAN/evaluations/gen_interpolated_images.py | """
Example:
python evaluations/gen_interpolated_images.py --n_zs=10 --n_intp=10 --snapshot=ResNetGenerator_850000.npz --config=configs/sn_projection.yml --classes 986 989
"""
import os, sys, time
import shutil
import numpy as np
import argparse
import chainer
from PIL import Image
base = os.path.dirname(os.path.absp... | 2,812 | 37.534247 | 158 | py |
GANFingerprints | GANFingerprints-master/SNGAN/evaluations/calc_inception_score.py | import os, sys
import numpy as np
import argparse
import chainer
base = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(base, '../'))
from evaluation import gen_images
import yaml
import source.yaml_utils as yaml_utils
def load_models(config):
gen_conf = config.models['generator']
gen... | 2,147 | 33.645161 | 83 | py |
GANFingerprints | GANFingerprints-master/SNGAN/evaluations/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/SNGAN/evaluations/gen_images.py | import os, sys, time
import shutil
import numpy as np
import argparse
import chainer
from PIL import Image
base = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(base, '../'))
from evaluation import gen_images_with_condition
import yaml
import source.yaml_utils as yaml_utils
def load_models(c... | 2,336 | 37.95 | 119 | py |
GANFingerprints | GANFingerprints-master/SNGAN/datasets/lsun_bedroom_200k.py | import numpy as np
from PIL import Image
import chainer
import random
import scipy.misc
class LSUNBedroom200kDataset(chainer.dataset.DatasetMixin):
def __init__(self, path, root, size=128, resize_method='bilinear', augmentation=False, crop_ratio=1.0):
self.base = chainer.datasets.LabeledImageDataset(path,... | 1,358 | 28.543478 | 107 | py |
GANFingerprints | GANFingerprints-master/SNGAN/datasets/celeba.py | import numpy as np
from PIL import Image
import chainer
import random
import scipy.misc
class CelebADataset(chainer.dataset.DatasetMixin):
def __init__(self, path, root, size=128, resize_method='bilinear', augmentation=False, crop_ratio=1.0):
self.base = chainer.datasets.LabeledImageDataset(path, root)
... | 1,352 | 28.413043 | 107 | py |
GANFingerprints | GANFingerprints-master/SNGAN/dis_models/snresnet_256.py | import chainer
from chainer import functions as F
from source.links.sn_embed_id import SNEmbedID
from source.links.sn_linear import SNLinear
from dis_models.resblocks import Block, OptimizedBlock
class SNResNetProjectionDiscriminator(chainer.Chain):
def __init__(self, ch=64, n_classes=0, activation=F.relu):
... | 1,727 | 41.146341 | 90 | py |
GANFingerprints | GANFingerprints-master/SNGAN/dis_models/snresnet.py | import chainer
from chainer import functions as F
from source.links.sn_embed_id import SNEmbedID
from source.links.sn_linear import SNLinear
from dis_models.resblocks import Block, OptimizedBlock
class SNResNetProjectionDiscriminator(chainer.Chain):
def __init__(self, ch=64, n_classes=0, activation=F.relu):
... | 3,224 | 42 | 97 | py |
GANFingerprints | GANFingerprints-master/SNGAN/dis_models/snresnet_small.py | import chainer
from chainer import functions as F
from source.links.sn_embed_id import SNEmbedID
from source.links.sn_linear import SNLinear
from dis_models.resblocks import Block, OptimizedBlock
class SNResNetProjectionDiscriminator(chainer.Chain):
def __init__(self, ch=64, n_classes=0, activation=F.relu):
... | 1,625 | 40.692308 | 88 | py |
GANFingerprints | GANFingerprints-master/SNGAN/dis_models/snresnet_64.py | import chainer
from chainer import functions as F
from source.links.sn_embed_id import SNEmbedID
from source.links.sn_linear import SNLinear
from dis_models.resblocks import Block, OptimizedBlock
class SNResNetProjectionDiscriminator(chainer.Chain):
def __init__(self, ch=64, n_classes=0, activation=F.relu):
... | 1,512 | 39.891892 | 88 | py |
GANFingerprints | GANFingerprints-master/SNGAN/dis_models/resblocks.py | import math
import chainer
from chainer import functions as F
from source.links.sn_convolution_2d import SNConvolution2D
def _downsample(x):
# Downsample (Mean Avg Pooling with 2x2 kernel)
return F.average_pooling_2d(x, 2)
class Block(chainer.Chain):
def __init__(self, in_channels, out_channels, hidden_... | 2,764 | 35.381579 | 112 | py |
GANFingerprints | GANFingerprints-master/SNGAN/dis_models/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/SNGAN/gen_models/resnet_small.py | import chainer
import chainer.links as L
from chainer import functions as F
from gen_models.resblocks import Block
from source.miscs.random_samples import sample_categorical, sample_continuous
class ResNetGenerator(chainer.Chain):
def __init__(self, ch=64, dim_z=128, bottom_width=4, activation=F.relu, n_classes=0... | 2,396 | 50 | 116 | py |
GANFingerprints | GANFingerprints-master/SNGAN/gen_models/resnet_64.py | import chainer
import chainer.links as L
from chainer import functions as F
from gen_models.resblocks import Block
from source.miscs.random_samples import sample_categorical, sample_continuous
class ResNetGenerator(chainer.Chain):
def __init__(self, ch=64, dim_z=128, bottom_width=4, activation=F.relu, n_classes=0... | 2,251 | 49.044444 | 116 | py |
GANFingerprints | GANFingerprints-master/SNGAN/gen_models/resnet_256.py | import chainer
import chainer.links as L
from chainer import functions as F
from gen_models.resblocks import Block
from source.miscs.random_samples import sample_categorical, sample_continuous
class ResNetGenerator(chainer.Chain):
def __init__(self, ch=64, dim_z=128, bottom_width=4, activation=F.relu, n_classes=0... | 2,547 | 51 | 116 | py |
GANFingerprints | GANFingerprints-master/SNGAN/gen_models/resnet.py | import chainer
import chainer.links as L
from chainer import functions as F
from gen_models.resblocks import Block
from source.miscs.random_samples import sample_categorical, sample_continuous
class ResNetGenerator(chainer.Chain):
def __init__(self, ch=64, dim_z=128, bottom_width=4, activation=F.relu, n_classes=0... | 2,401 | 50.106383 | 117 | py |
GANFingerprints | GANFingerprints-master/SNGAN/gen_models/resblocks.py | import math
import chainer
import chainer.links as L
from chainer import functions as F
from source.links.categorical_conditional_batch_normalization import CategoricalConditionalBatchNormalization
def _upsample(x):
h, w = x.shape[2:]
return F.unpooling_2d(x, 2, outsize=(h * 2, w * 2))
def upsample_conv(x, ... | 2,458 | 40.677966 | 112 | py |
GANFingerprints | GANFingerprints-master/SNGAN/gen_models/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/SNGAN/source/yaml_utils.py | # !/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import os
import shutil
import sys
import time
import yaml
# Copy from tgans repo.
class Config(object):
def __init__(self, config_dict):
self.config = config_dict
def __getattr__(self, key):
if key in self.config:
r... | 1,201 | 20.464286 | 68 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/SNGAN/source/functions/max_sv.py | import chainer.functions as F
from chainer import cuda
def _l2normalize(v, eps=1e-12):
norm = cuda.reduce('T x', 'T out',
'x * x', 'a + b', 'out = sqrt(a)', 0,
'norm_sn')
div = cuda.elementwise('T x, T norm, T eps',
'T out',
... | 1,678 | 31.921569 | 85 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/functions/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/SNGAN/source/inception/inception_score_tf.py | # Code derived from https://github.com/openai/improved-gan/tree/master/inception_score
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os.path
import sys
import tarfile
import numpy as np
from six.moves import urllib
import tensorflow as tf
import gl... | 5,784 | 35.613924 | 113 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/inception/download.py | # code drived from https://github.com/hvy/chainer-inception-score
"""
Including code from the official implementation by OpenAI found at
https://github.com/openai/improved-gan
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import os.pat... | 10,506 | 41.538462 | 128 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/inception/inception_score.py | # code drived from https://github.com/hvy/chainer-inception-score
import math
import chainer
from chainer import Chain
from chainer import functions as F
from chainer import links as L
from chainer import Variable
def inception_forward(model, ims, batch_size):
n, c, w, h = ims.shape
n_batches = int(math.cei... | 28,246 | 42.059451 | 98 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/inception/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/SNGAN/source/links/sn_embed_id.py | from chainer.functions.connection import embed_id
from chainer.initializers import normal
from chainer import link
from chainer import variable
from chainer.functions.array.broadcast import broadcast_to
from source.functions.max_sv import max_singular_value
import numpy as np
class SNEmbedID(link.Link):
"""Effici... | 2,924 | 40.197183 | 95 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/links/conditional_batch_normalization.py | import numpy
import chainer
from chainer import configuration
from chainer import cuda
from chainer.functions.normalization import batch_normalization
from chainer import initializers
from chainer import link
from chainer.utils import argument
from chainer import variable
from chainer.links import EmbedID
import chain... | 5,186 | 44.5 | 115 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/links/sn_linear.py | import chainer
import numpy as np
from chainer.functions.array.broadcast import broadcast_to
from chainer.functions.connection import linear
from chainer.links.connection.linear import Linear
from source.functions.max_sv import max_singular_value
class SNLinear(Linear):
"""Linear layer with Spectral Normalization... | 3,641 | 38.586957 | 87 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/links/categorical_conditional_batch_normalization.py | import numpy
import chainer
from chainer import configuration
from chainer import cuda
from chainer.functions.normalization import batch_normalization
from chainer import initializers
from chainer import link
from chainer.utils import argument
from chainer import variable
from chainer.links import EmbedID
import chain... | 4,747 | 45.097087 | 107 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/links/sn_convolution_nd.py | import numpy as np
from chainer.functions.connection import convolution_nd
from chainer import initializers
from chainer import link
from chainer.utils import conv_nd
from chainer import variable
from chainer.functions.array.broadcast import broadcast_to
from source.functions.max_sv import max_singular_value
class S... | 5,130 | 43.617391 | 87 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/links/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/SNGAN/source/links/sn_convolution_2d.py | import chainer
import numpy as np
from chainer import cuda
from chainer.functions.array.broadcast import broadcast_to
from chainer.functions.connection import convolution_2d
from chainer.links.connection.convolution_2d import Convolution2D
from source.functions.max_sv import max_singular_value
class SNConvolution2D(C... | 4,687 | 42.009174 | 101 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/miscs/random_samples.py | import numpy as np
import chainer
def sample_continuous(dim, batchsize, distribution='normal', xp=np):
if distribution == "normal":
return xp.random.randn(batchsize, dim) \
.astype(xp.float32)
elif distribution == "uniform":
return xp.random.uniform(-1, 1, (batchsize, dim)) \
... | 1,099 | 31.352941 | 86 | py |
GANFingerprints | GANFingerprints-master/SNGAN/source/miscs/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/main.py | import sys
import numpy as np
import core
from utils.misc import pp, visualize
import tensorflow as tf
flags = tf.app.flags
flags.DEFINE_integer("max_iteration", 150000, "Epoch to train [150000]")
flags.DEFINE_float("learning_rate", .0001, "Learning rate [.0001]")
flags.DEFINE_float("learning_rate_D", -1, "Learning r... | 7,225 | 53.330827 | 191 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/compute_scores.py | from __future__ import division, print_function
import os.path, sys, tarfile
import numpy as np
from scipy import linalg
from six.moves import range, urllib
from sklearn.metrics.pairwise import polynomial_kernel
import tensorflow as tf
from tqdm import tqdm
# from tqdm docs: https://pypi.python.org/pypi/tqdm#hooks-a... | 18,512 | 35.087719 | 119 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/summarize.py | import argparse
import os
import numpy as np
parser = argparse.ArgumentParser()
parser.add_argument('files', nargs='+')
parser.add_argument('--tex', action='store_true')
args = parser.parse_args()
if args.tex:
split = ' & '
end = '\\\\\n'
else:
split = ' '
end = '\n'
print(' ' * 79 + 'Inceptio... | 1,506 | 30.395833 | 77 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/architecture.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 10 14:34:47 2018
@author: mikolajbinkowski
"""
import tensorflow as tf
from core.ops import batch_norm, conv2d, deconv2d, linear, lrelu
from utils.misc import conv_sizes
# Generators
class Generator:
def __init__(self, dim, c_dim, output_size, ... | 9,781 | 42.475556 | 115 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/cramer.py | from .model import MMD_GAN, tf, np
from .architecture import get_networks
from .ops import safer_norm
class Cramer_GAN(MMD_GAN):
def build_model(self):
self.global_step = tf.Variable(0, name="global_step", trainable=False)
self.lr = tf.Variable(self.config.learning_rate, name='lr... | 4,955 | 50.625 | 116 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/mmd.py | '''
MMD functions implemented in tensorflow.
'''
from __future__ import division
_eps=1.0e-5
import tensorflow as tf
import numpy as np
from .ops import dot, sq_sum
mysqrt = lambda x: tf.sqrt(tf.maximum(x + _eps, 0.))
def _distance_kernel(X, Y, K_XY_only=False):
XX = tf.matmul(X, X, transpose_b=True)
XY = t... | 17,404 | 33.465347 | 102 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/model.py | from __future__ import division, print_function
import os, sys, time, pprint, numpy as np
from . import mmd
from .ops import safer_norm, tf
from .architecture import get_networks
from .pipeline import get_pipeline
from utils import timer, scorer, misc
class MMD_GAN(object):
def __init__(self, sess, config,
... | 21,413 | 44.464968 | 133 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/wgan_gp.py | from .model import MMD_GAN, tf
class WGAN_GP(MMD_GAN):
def __init__(self, sess, config, **kwargs):
config.dof_dim = 1
super(WGAN_GP, self).__init__(sess, config, **kwargs)
def set_loss(self, G, images):
alpha = tf.random_uniform(shape=[self.batch_size, 1, 1, 1])
real_d... | 1,240 | 41.793103 | 93 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/__init__.py | __all__= ['model', 'wgan_gp', 'cramer', 'ops', 'mmd', 'resnet', 'architecture']
| 80 | 39.5 | 79 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/ops.py | from tensorflow.python.framework import ops
from utils.misc import variable_summaries
from .mmd import _eps, tf
class batch_norm(object):
def __init__(self, epsilon=1e-5, momentum = 0.9, name="batch_norm"):
with tf.variable_scope(name):
self.epsilon = epsilon
self.momentum = momentum
self.nam... | 7,220 | 38.244565 | 104 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/pipeline.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 11 14:11:46 2018
@author: mikolajbinkowski
"""
import os, time, lmdb, io
import numpy as np
import tensorflow as tf
from PIL import Image
from glob import glob
import matplotlib.pyplot as plt
from utils import misc
class Pipeline:
def __init__(... | 11,697 | 39.337931 | 139 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/block.py | """
Based on https://github.com/igul222/improved_wgan_training/blob/master/gan_64x64.py.
"""
import functools
import tensorflow as tf
from core.resnet.ops import conv2d, batchnorm, layernorm
def ResidualBlock(name, input_dim, output_dim, filter_size, inputs, resample=None, he_init=True):
"""
resample: None, '... | 3,394 | 44.266667 | 116 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/__init__.py | import numpy as np
import tensorflow as tf
import locale
locale.setlocale(locale.LC_ALL, '')
__all__ = ['block', 'ops']
_params = {}
_param_aliases = {}
def param(name, *args, **kwargs):
"""
A wrapper for `tf.Variable` which enables parameter sharing in models.
Creates and returns theano shared varia... | 1,889 | 29 | 119 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.