(self)
Initialize the discriminator and generator networks.

        In order to make sure that the discriminator is providing useful gradient
        information to the generator from the start, we can pretrain the
        discriminator using a maximum likelihood objective. We define the network
        for this pretraining step scoped as D_pre.
Initialize the discriminator and generator networks.
Initialize the discriminator and generator networks .
def _create_networks(self):
        """Initialize the discriminator and generator networks.

        In order to make sure that the discriminator is providing useful gradient
        information to the generator from the start, we can pretrain the
        discriminator using a maximum likelihood objective. We define the network
        for this pretraining step scoped as D_pre.
        """
        # Pretrain (optional).
        if self.d_pretrain:
            with tf.variable_scope('D_pre'):
                self.pre_input = tf.placeholder(tf.float32, shape=(
                    self.batch_size, self.net_arch['n_input']))
                self.pre_labels = tf.placeholder(tf.float32, shape=(
                    self.batch_size, self.net_arch['n_input']))
                D_pre = self._discriminator(self.pre_input,
                                            self.net_arch['d_hidden_dim'],
                                            stddev=self.stddev)
                self.pre_loss = tf.reduce_mean(
                    tf.square(D_pre - self.pre_labels))
                self.pre_opt = optimizer(self.pre_loss, None)

        # Define the generator network.
        with tf.variable_scope('G'):
            self.z = tf.placeholder(tf.float32,
                                    [None, self.net_arch['n_input']],
                                    name='z')
            self.G = self._generator(self.z,
                                     self.net_arch['g_hidden_dim'],
                                     self.net_arch['n_output'],
                                     batch_norm=True,
                                     stddev=self.stddev)

        # Define the discriminator network.
        with tf.variable_scope('D') as scope:
            self.x = tf.placeholder(tf.float32,
                [None, self.net_arch['n_output']], name='x')
            self.D1 = self._discriminator(
                self.x, self.net_arch['d_hidden_dim'], stddev=self.stddev)
            scope.reuse_variables()
            self.D2 = self._discriminator(
                self.G, self.net_arch['d_hidden_dim'], stddev=self.stddev)
def _create_networks ( self ) : # Pretrain (optional). if self . d_pretrain : with tf . variable_scope ( 'D_pre' ) : self . pre_input = tf . placeholder ( tf . float32 , shape = ( self . batch_size , self . net_arch [ 'n_input' ] ) ) self . pre_labels = tf . placeholder ( tf . float32 , shape = ( self . batch_size , self . net_arch [ 'n_input' ] ) ) D_pre = self . _discriminator ( self . pre_input , self . net_arch [ 'd_hidden_dim' ] , stddev = self . stddev ) self . pre_loss = tf . reduce_mean ( tf . square ( D_pre - self . pre_labels ) ) self . pre_opt = optimizer ( self . pre_loss , None ) # Define the generator network. with tf . variable_scope ( 'G' ) : self . z = tf . placeholder ( tf . float32 , [ None , self . net_arch [ 'n_input' ] ] , name = 'z' ) self . G = self . _generator ( self . z , self . net_arch [ 'g_hidden_dim' ] , self . net_arch [ 'n_output' ] , batch_norm = True , stddev = self . stddev ) # Define the discriminator network. with tf . variable_scope ( 'D' ) as scope : self . x = tf . placeholder ( tf . float32 , [ None , self . net_arch [ 'n_output' ] ] , name = 'x' ) self . D1 = self . _discriminator ( self . x , self . net_arch [ 'd_hidden_dim' ] , stddev = self . stddev ) scope . reuse_variables ( ) self . D2 = self . _discriminator ( self . G , self . net_arch [ 'd_hidden_dim' ] , stddev = self . stddev )