Beispiel #1
0
  def __call__(self, D):
    with tf.variable_scope(self.name, reuse=self.reuse):
        
        D_norm = D 
        
        G_conv1 = utils.conv2d_basic(D_norm, self.Param['G_W1'], self.Param['G_b1'])
        G_relu1 = tf.nn.relu(G_conv1, name="G_relu1")
    
        G_conv2 = utils.conv2d_basic(G_relu1, self.Param['G_W2'], self.Param['G_b2'])
        G_relu2 = tf.nn.relu(G_conv2, name="G_relu2")
        
        G_pool1 = utils.max_pool_2x2(G_relu2)
        
        G_conv3 = utils.conv2d_basic(G_pool1, self.Param['G_W3'], self.Param['G_b3'])
        G_relu3 = tf.nn.relu(G_conv3, name="G_relu3")
        
        G_conv4 = utils.conv2d_basic(G_relu3, self.Param['G_W4'], self.Param['G_b4'])
        G_relu4 = tf.nn.relu(G_conv4, name="G_relu4")
        
        G_pool2 = utils.max_pool_2x2(G_relu4)
        
        G_conv5 = utils.conv2d_basic(G_pool2, self.Param['G_W5'], self.Param['G_b5'])
        G_relu5 = tf.nn.relu(G_conv5, name="G_relu5")
        
        output_shape = G_relu5.get_shape().as_list()
        output_shape[1] *= 2
        output_shape[2] *= 2
        output_shape[3] = self.Param['G_W6'].get_shape().as_list()[2]
           
        G_rs6 = tf.image.resize_images(G_relu5, output_shape[1:3], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR) 
        G_conv6 = utils.conv2d_basic(G_rs6, self.Param['G_W6'], self.Param['G_b6'])
        G_relu6 = tf.nn.relu(G_conv6, name="G_rs6")
        
        output_shape = G_relu6.get_shape().as_list()
        output_shape[1] *= 2
        output_shape[2] *= 2
        output_shape[3] = self.Param['G_W7'].get_shape().as_list()[2]
    
        G_rs7 = tf.image.resize_images(G_relu6, output_shape[1:3], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR) 
        G_conv7 = utils.conv2d_basic(G_rs7, self.Param['G_W7'], self.Param['G_b7'])
        G_relu7 = tf.nn.relu(G_conv7, name="G_rs7")
        
        G_conv8 = utils.conv2d_basic(G_relu7, self.Param['G_W8'], self.Param['G_b8'])
        G_relu8 = tf.nn.relu(G_conv8, name="G_relu8")
        
        G_conv9 = utils.conv2d_basic(G_relu8, self.Param['G_W9'], self.Param['G_b9'])
        Gama = tf.nn.softmax(G_conv9, name="G_latent_softmax")
        

    return Gama
  def __call__(self, D):
    with tf.variable_scope(self.name, reuse=self.reuse):
        
        D_norm = D 
        
        G_conv1 = utils.conv2d_basic(D_norm, self.Param['G_W1'], self.Param['G_b1'])
        G_relu1 = tf.nn.relu(G_conv1, name="G_relu1")
    
        G_conv2 = utils.conv2d_basic(G_relu1, self.Param['G_W2'], self.Param['G_b2'])
        G_relu2 = tf.nn.relu(G_conv2, name="G_relu2")
        
        G_pool1 = utils.max_pool_2x2(G_relu2)
        
        G_conv3 = utils.conv2d_basic(G_pool1, self.Param['G_W3'], self.Param['G_b3'])
        G_relu3 = tf.nn.relu(G_conv3, name="G_relu3")
        
        G_conv4 = utils.conv2d_basic(G_relu3, self.Param['G_W4'], self.Param['G_b4'])
        G_relu4 = tf.nn.relu(G_conv4, name="G_relu4")
        
        G_pool2 = utils.max_pool_2x2(G_relu4)
        
        G_conv5 = utils.conv2d_basic(G_pool2, self.Param['G_W5'], self.Param['G_b5'])
        G_relu5 = tf.nn.relu(G_conv5, name="G_relu5")
        
        output_shape = G_relu5.get_shape().as_list()
        output_shape[1] *= 2
        output_shape[2] *= 2
        output_shape[3] = self.Param['G_W6'].get_shape().as_list()[2]
           
        G_rs6 = tf.image.resize_images(G_relu5, output_shape[1:3], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR) 
        G_conv6 = utils.conv2d_basic(G_rs6, self.Param['G_W6'], self.Param['G_b6'])
        G_relu6 = tf.nn.relu(G_conv6, name="G_rs6")
        
        output_shape = G_relu6.get_shape().as_list()
        output_shape[1] *= 2
        output_shape[2] *= 2
        output_shape[3] = self.Param['G_W7'].get_shape().as_list()[2]
    
        G_rs7 = tf.image.resize_images(G_relu6, output_shape[1:3], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR) 
        G_conv7 = utils.conv2d_basic(G_rs7, self.Param['G_W7'], self.Param['G_b7'])
        G_relu7 = tf.nn.relu(G_conv7, name="G_rs7")
        
        G_conv8 = utils.conv2d_basic(G_relu7, self.Param['G_W8'], self.Param['G_b8'])
        G_relu8 = tf.nn.relu(G_conv8, name="G_relu8")
        
        G_conv9 = utils.conv2d_basic(G_relu8, self.Param['G_W9'], self.Param['G_b9'])
        Gama = tf.nn.softmax(G_conv9, name="G_latent_softmax")
        

    return Gama
    def __call__(self, D):
        with tf.variable_scope(self.name, reuse=self.reuse):

            D_norm = D
            G_conv1 = utils.conv2d_basic(D_norm, self.Param['G_W1'],
                                         self.Param['G_b1'])
            G_relu1 = tf.nn.relu(G_conv1, name="G_relu1")

            G_conv2 = utils.conv2d_basic(G_relu1, self.Param['G_W2'],
                                         self.Param['G_b2'])
            G_relu2 = tf.nn.relu(G_conv2, name="G_relu2")

            G_pool1 = utils.max_pool_2x2(G_relu2)
            G_conv3 = utils.conv2d_basic(G_pool1, self.Param['G_W3'],
                                         self.Param['G_b3'])
            G_relu3 = tf.nn.relu(G_conv3, name="G_relu3")

            G_conv4 = utils.conv2d_basic(G_relu3, self.Param['G_W4'],
                                         self.Param['G_b4'])
            G_relu4 = tf.nn.relu(G_conv4, name="G_relu4")

            G_pool2 = utils.max_pool_2x2(G_relu4)

            G_conv5 = utils.conv2d_basic(G_pool2, self.Param['G_W5'],
                                         self.Param['G_b5'])
            G_relu5 = tf.nn.relu(G_conv5, name="G_relu5")

            G_conv6 = utils.conv2d_basic(G_relu5, self.Param['G_W6'],
                                         self.Param['G_b6'])
            G_relu6 = tf.nn.relu(G_conv6, name="G_relu6")

            G_conv7 = utils.conv2d_basic(G_relu6, self.Param['G_W7'],
                                         self.Param['G_b7'])
            G_relu7 = tf.nn.relu(G_conv7, name="G_relu7")

            G_pool3 = utils.max_pool_2x2(G_relu7)
            G_conv8 = utils.conv2d_basic(G_pool3, self.Param['G_W8'],
                                         self.Param['G_b8'])
            G_relu8 = tf.nn.relu(G_conv8, name="G_relu8")

            G_conv9 = utils.conv2d_basic(G_relu8, self.Param['G_W9'],
                                         self.Param['G_b9'])
            G_relu9 = tf.nn.relu(G_conv9, name="G_relu9")

            G_conv10 = utils.conv2d_basic(G_relu9, self.Param['G_W10'],
                                          self.Param['G_b10'])
            G_relu10 = tf.nn.relu(G_conv10, name="G_relu10")

            G_pool4 = utils.max_pool_2x2(G_relu10)
            G_conv11 = utils.conv2d_basic(G_pool4, self.Param['G_W11'],
                                          self.Param['G_b11'])
            G_relu11 = tf.nn.relu(G_conv11, name="G_relu11")

            G_conv12 = utils.conv2d_basic(G_relu11, self.Param['G_W12'],
                                          self.Param['G_b12'])
            G_relu12 = tf.nn.relu(G_conv12, name="G_relu12")

            G_conv13 = utils.conv2d_basic(G_relu12, self.Param['G_W13'],
                                          self.Param['G_b13'])
            G_relu13 = tf.nn.relu(G_conv13, name="G_relu13")

            G_rs14 = tf.image.resize_images(
                G_relu13, [63, 63],
                method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
            #G_rs14 = tf.image.resize_images(G_relu13, [64, 64], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
            G_cc14 = tf.concat([G_rs14, G_relu10], 3, name="G_cc14")

            G_conv14 = utils.conv2d_basic(G_cc14, self.Param['G_W14'],
                                          self.Param['G_b14'])
            G_relu14 = tf.nn.relu(G_conv14, name="G_rs14")

            G_rs15 = tf.image.resize_images(
                G_relu14, [125, 125],
                method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
            #G_rs15 = tf.image.resize_images(G_relu14, [128, 128], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
            G_cc15 = tf.concat([G_rs15, G_relu7], 3, name="G_cc15")

            G_conv15 = utils.conv2d_basic(G_cc15, self.Param['G_W15'],
                                          self.Param['G_b15'])
            G_relu15 = tf.nn.relu(G_conv15, name="G_rs15")

            G_rs16 = tf.image.resize_images(
                G_relu15, [250, 250],
                method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
            #G_rs16 = tf.image.resize_images(G_relu15, [256, 256], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
            G_cc16 = tf.concat([G_rs16, G_relu4], 3, name="G_cc16")

            G_conv16 = utils.conv2d_basic(G_cc16, self.Param['G_W16'],
                                          self.Param['G_b16'])
            G_relu16 = tf.nn.relu(G_conv16, name="G_rs16")

            G_rs17 = tf.image.resize_images(
                G_relu16, [500, 500],
                method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
            #G_rs17 = tf.image.resize_images(G_relu16, [512, 512], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
            G_cc17 = tf.concat([G_rs17, G_relu2], 3, name="G_cc17")

            G_conv17 = utils.conv2d_basic(G_cc17, self.Param['G_W17'],
                                          self.Param['G_b17'])
            G_relu17 = tf.nn.relu(G_conv17, name="G_rs17")

            G_conv18 = utils.conv2d_basic(G_relu17, self.Param['G_W18'],
                                          self.Param['G_b18'])
            G_relu18 = tf.nn.relu(G_conv18, name="G_relu18")

            G_conv19 = utils.conv2d_basic(G_relu18, self.Param['G_W19'],
                                          self.Param['G_b19'])
            Gama = tf.nn.softmax(G_conv19, name="G_latent_softmax")

        return Gama