学习tensorflow pix2pix

来源:互联网 发布:健康的零食 知乎 编辑:程序博客网 时间:2024/06/05 00:51
def generator(self, z):    self.z_, self.h0_w, self.h0_b = linear(z, self.gf_dim*8*4*4,                                           'g_h0_lin', with_w=True)    self.h0 = tf.reshape(self.z_, [-1, 4, 4, self.gf_dim * 8])    h0 = tf.nn.relu(self.g_bn0(self.h0))    self.h1, self.h1_w, self.h1_b = conv2d_transpose(h0,        [self.batch_size, 8, 8, self.gf_dim*4], name='g_h1', with_w=True)    h1 = tf.nn.relu(self.g_bn1(self.h1))    h2, self.h2_w, self.h2_b = conv2d_transpose(h1,        [self.batch_size, 16, 16, self.gf_dim*2], name='g_h2', with_w=True)    h2 = tf.nn.relu(self.g_bn2(h2))    h3, self.h3_w, self.h3_b = conv2d_transpose(h2,        [self.batch_size, 32, 32, self.gf_dim*1], name='g_h3', with_w=True)    h3 = tf.nn.relu(self.g_bn3(h3))    h4, self.h4_w, self.h4_b = conv2d_transpose(h3,        [self.batch_size, 64, 64, 3], name='g_h4', with_w=True)    return tf.nn.tanh(h4)def discriminator(self, image, reuse=False):    if reuse:        tf.get_variable_scope().reuse_variables()    h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv'))    h1 = lrelu(self.d_bn1(conv2d(h0, self.df_dim*2, name='d_h1_conv')))    h2 = lrelu(self.d_bn2(conv2d(h1, self.df_dim*4, name='d_h2_conv')))    h3 = lrelu(self.d_bn3(conv2d(h2, self.df_dim*8, name='d_h3_conv')))    h4 = linear(tf.reshape(h3, [-1, 8192]), 1, 'd_h3_lin')
def generator(self, z):    self.z_, self.h0_w, self.h0_b = linear(z, self.gf_dim*8*4*4,                                           'g_h0_lin', with_w=True)    self.h0 = tf.reshape(self.z_, [-1, 4, 4, self.gf_dim * 8])    h0 = tf.nn.relu(self.g_bn0(self.h0))    self.h1, self.h1_w, self.h1_b = conv2d_transpose(h0,        [self.batch_size, 8, 8, self.gf_dim*4], name='g_h1', with_w=True)    h1 = tf.nn.relu(self.g_bn1(self.h1))    h2, self.h2_w, self.h2_b = conv2d_transpose(h1,        [self.batch_size, 16, 16, self.gf_dim*2], name='g_h2', with_w=True)    h2 = tf.nn.relu(self.g_bn2(h2))    h3, self.h3_w, self.h3_b = conv2d_transpose(h2,        [self.batch_size, 32, 32, self.gf_dim*1], name='g_h3', with_w=True)    h3 = tf.nn.relu(self.g_bn3(h3))    h4, self.h4_w, self.h4_b = conv2d_transpose(h3,        [self.batch_size, 64, 64, 3], name='g_h4', with_w=True)    return tf.nn.tanh(h4)def discriminator(self, image, reuse=False):    if reuse:        tf.get_variable_scope().reuse_variables()    h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv'))    h1 = lrelu(self.d_bn1(conv2d(h0, self.df_dim*2, name='d_h1_conv')))    h2 = lrelu(self.d_bn2(conv2d(h1, self.df_dim*4, name='d_h2_conv')))    h3 = lrelu(self.d_bn3(conv2d(h2, self.df_dim*8, name='d_h3_conv')))    h4 = linear(tf.reshape(h3, [-1, 8192]), 1, 'd_h3_lin')    return tf.nn.sigmoid(h4), h4

return tf.nn.sigmoid(h4), h4
0 0
原创粉丝点击