(self)
Sets up the model graph in TensorFlow.
Sets up the model graph in TensorFlow.
Sets up the model graph in TensorFlow .
def define_graph(self):
        """
        Sets up the model graph in TensorFlow.
        """
        with tf.name_scope('discriminator'):
            ##
            # Setup scale networks. Each will make the predictions for images at a given scale.
            ##

            self.scale_nets = []
            for scale_num in xrange(self.num_scale_nets):
                with tf.name_scope('scale_net_' + str(scale_num)):
                    scale_factor = 1. / 2 ** ((self.num_scale_nets - 1) - scale_num)
                    self.scale_nets.append(DScaleModel(scale_num,
                                                       int(self.height * scale_factor),
                                                       int(self.width * scale_factor),
                                                       self.scale_conv_layer_fms[scale_num],
                                                       self.scale_kernel_sizes[scale_num],
                                                       self.scale_fc_layer_sizes[scale_num]))

            # A list of the prediction tensors for each scale network
            self.scale_preds = []
            for scale_num in xrange(self.num_scale_nets):
                self.scale_preds.append(self.scale_nets[scale_num].preds)

            ##
            # Data
            ##

            self.labels = tf.placeholder(tf.float32, shape=[None, 1], name='labels')

            ##
            # Training
            ##

            with tf.name_scope('training'):
                # global loss is the combined loss from every scale network
                self.global_loss = adv_loss(self.scale_preds, self.labels)
                self.global_step = tf.Variable(0, trainable=False, name='global_step')
                self.optimizer = tf.train.GradientDescentOptimizer(c.LRATE_D, name='optimizer')
                self.train_op = self.optimizer.minimize(self.global_loss,
                                                        global_step=self.global_step,
                                                        name='train_op')

                # add summaries to visualize in TensorBoard
                loss_summary = tf.scalar_summary('loss_D', self.global_loss)
                self.summaries = tf.merge_summary([loss_summary])
def define_graph ( self ) : with tf . name_scope ( 'discriminator' ) : ## # Setup scale networks. Each will make the predictions for images at a given scale. ## self . scale_nets = [ ] for scale_num in xrange ( self . num_scale_nets ) : with tf . name_scope ( 'scale_net_' + str ( scale_num ) ) : scale_factor = 1. / 2 ** ( ( self . num_scale_nets - 1 ) - scale_num ) self . scale_nets . append ( DScaleModel ( scale_num , int ( self . height * scale_factor ) , int ( self . width * scale_factor ) , self . scale_conv_layer_fms [ scale_num ] , self . scale_kernel_sizes [ scale_num ] , self . scale_fc_layer_sizes [ scale_num ] ) ) # A list of the prediction tensors for each scale network self . scale_preds = [ ] for scale_num in xrange ( self . num_scale_nets ) : self . scale_preds . append ( self . scale_nets [ scale_num ] . preds ) ## # Data ## self . labels = tf . placeholder ( tf . float32 , shape = [ None , 1 ] , name = 'labels' ) ## # Training ## with tf . name_scope ( 'training' ) : # global loss is the combined loss from every scale network self . global_loss = adv_loss ( self . scale_preds , self . labels ) self . global_step = tf . Variable ( 0 , trainable = False , name = 'global_step' ) self . optimizer = tf . train . GradientDescentOptimizer ( c . LRATE_D , name = 'optimizer' ) self . train_op = self . optimizer . minimize ( self . global_loss , global_step = self . global_step , name = 'train_op' ) # add summaries to visualize in TensorBoard loss_summary = tf . scalar_summary ( 'loss_D' , self . global_loss ) self . summaries = tf . merge_summary ( [ loss_summary ] )