<commit_before>from hypergan.util.ops import *
from hypergan.util.globals import *
from hypergan.util.hc_tf import *
import tensorflow as tf
import hypergan.util.wavegan as wavegan
import hyperchamber as hc
TINY = 1e-12

class Graph:
    def __init__(self, config={}):
        self.config = config

    def generator(self, inputs, reuse=False):
        config = self.config
        x_dims = config['x_dims']
        output_channels = config['channels']
        activation = config['generator.activation']
        batch_size = config['batch_size']
        z_proj_dims = int(config['generator.z_projection_depth'])
        batch_norm = config['generator.regularizers.layer']

        with(tf.variable_scope("generator", reuse=reuse)):
            output_shape = x_dims[0]*x_dims[1]*config['channels']
            primes = find_smallest_prime(x_dims[0], x_dims[1])
            dropout = tf.Variable(0.5)
            set_tensor("dropout", dropout)

            original_z = tf.concat(1, inputs)
            layers = config['generator.fully_connected_layers']
            net = original_z
            for i in range(layers):
                net = linear(net, net.get_shape()[-1], scope="g_fc_"+str(i))
                net = batch_norm(batch_size, name='g_rp_bn'+str(i))(net)
                net = activation(net)

            set_tensor('original_z', net)
            net = linear(net, z_proj_dims*primes[0]*primes[1], scope="g_lin_proj", regularizer=tf.contrib.layers.l2_regularizer(config['generator.regularizers.l2.lambda']))
            new_shape = [config['batch_size'], primes[0],primes[1],z_proj_dims]
            net = tf.reshape(net, new_shape)

            nets = config['generator'](config, net)

            return nets

    def discriminator(self, x, f,z,g,gz):
        config = self.config
        batch_size = config['batch_size']*2
        single_batch_size = config['batch_size']
        channels = (config['channels'])
        # combine to one batch, per Ian's "Improved GAN"
        xs = [x]
        gs = g
        set_tensor("xs", xs)
        set_tensor("gs", gs)
        g = g[-1]
        for i in gs:
            resized = tf.image.resize_images(xs[-1],[int(xs[-1].get_shape()[1]//2),int(xs[-1].get_shape()[2]//2)], 1)
            xs.append(resized)
        xs.pop()
        gs.reverse()

        # careful on order.  See https://arxiv.org/pdf/1606.00704v1.pdf
        z = tf.concat(0, [z, gz])

        discriminators = []
        for i, discriminator in enumerate(config['discriminators']):<commit_msg>[fix] pass z to generator<commit_after>from hypergan.util.ops import *
from hypergan.util.globals import *
from hypergan.util.hc_tf import *
import tensorflow as tf
import hypergan.util.wavegan as wavegan
import hyperchamber as hc
TINY = 1e-12

class Graph:
    def __init__(self, config={}):
        self.config = config

    def generator(self, inputs, reuse=False):
        config = self.config
        x_dims = config['x_dims']
        output_channels = config['channels']
        activation = config['generator.activation']
        batch_size = config['batch_size']
        z_proj_dims = int(config['generator.z_projection_depth'])
        batch_norm = config['generator.regularizers.layer']

        with(tf.variable_scope("generator", reuse=reuse)):
            output_shape = x_dims[0]*x_dims[1]*config['channels']
            primes = find_smallest_prime(x_dims[0], x_dims[1])

            original_z = tf.concat(1, inputs)
            layers = config['generator.fully_connected_layers']
            net = original_z
            for i in range(layers):
                net = linear(net, net.get_shape()[-1], scope="g_fc_"+str(i))
                net = batch_norm(batch_size, name='g_rp_bn'+str(i))(net)
                net = activation(net)

            net = linear(net, z_proj_dims*primes[0]*primes[1], scope="g_lin_proj", regularizer=tf.contrib.layers.l2_regularizer(config['generator.regularizers.l2.lambda']))
            new_shape = [config['batch_size'], primes[0],primes[1],z_proj_dims]
            net = tf.reshape(net, new_shape)

            nets = config['generator'](config, net, original_z)

            return nets

    def discriminator(self, x, f,z,g,gz):
        config = self.config
        batch_size = config['batch_size']*2
        single_batch_size = config['batch_size']
        channels = (config['channels'])
        # combine to one batch, per Ian's "Improved GAN"
        xs = [x]
        gs = g
        set_tensor("xs", xs)
        set_tensor("gs", gs)
        g = g[-1]
        for i in gs:
            resized = tf.image.resize_images(xs[-1],[int(xs[-1].get_shape()[1]//2),int(xs[-1].get_shape()[2]//2)], 1)
            xs.append(resized)
        xs.pop()
        gs.reverse()

        # careful on order.  See https://arxiv.org/pdf/1606.00704v1.pdf
        z = tf.concat(0, [z, gz])

        discriminators = []
        for i, discriminator in enumerate(config['discriminators']):
{'fraction_non_alphanumeric': 0.13638203156616754, 'fraction_numerical': 0.014973694860380412, 'mean_word_length': 2.558675305975522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1154061', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1568, 'n_words': 302}