Beispiel #1
0
def Generator_k(z, labels=None, reuse=False, nums=50):
    with tf.variable_scope("Generator") as scope:
        if reuse:
            scope.reuse_variables()
        if z is None:
            z = tf.random_normal([nums, FLAGS.z_dim])
        if labels is not None:
            z = tf.concat([z, labels], 1)
        z_labels = tlib.fc(z, 4 * 4 * 4 * FLAGS.DIM, scope="project")
        bn1 = tlib.bn(z_labels, scope="bn1")
        out_put = tf.nn.relu(bn1)
        out_put = tf.reshape(out_put, [-1, 4, 4, 4 * FLAGS.DIM])
        dconv1 = tlib.Con2D_transpose(out_put, [nums, 8, 8, 2 * FLAGS.DIM],
                                      5,
                                      2,
                                      scope="conv2D_transpose1")
        bnconv1 = tlib.bn(dconv1, scope="bn2")
        h1 = tf.nn.relu(bnconv1)
        dconv2 = tlib.Con2D_transpose(h1, [nums, 16, 16, FLAGS.DIM],
                                      5,
                                      2,
                                      scope="conv2D_transpose2")
        bnconv2 = tlib.bn(dconv2, scope="bn3")
        h2 = tf.nn.relu(bnconv2)
        dconv3 = tlib.Con2D_transpose(h2, [nums, 32, 32, FLAGS.input_channel],
                                      5,
                                      2,
                                      scope="conv2D_transpose3")
        h3 = tf.tanh(dconv3)
    return tf.reshape(h3, [-1, FLAGS.Out_DIm])
Beispiel #2
0
def Generator(z,labels=None,reuse=False,nums=50):
    with tf.variable_scope("Generator") as scope:
        #z_labels = tf.concat([z,labels],1)
        if reuse:
            scope.reuse_variables()
        if z is None:
            z = tf.random_normal([nums,FLAGS.z_dim])
        if labels is not None:
            z = tf.concat([z,labels],1)
        oh,ow =flags.FLAGS.out_height,flags.FLAGS.out_width

        z_labels = tlib.fc(z,4*4*4*FLAGS.DIM,scope="project")

        out_put = tf.nn.relu(z_labels)

        out_put = tf.reshape(out_put,[-1,4,4,4*FLAGS.DIM])

        dconv1 = tlib.Con2D_transpose(out_put,[nums,8,8,2*FLAGS.DIM],5,2,scope="conv2D_transpose1")

        h1 = tf.nn.relu(dconv1)

        h1 = h1[:,:7,:7,:]

        dconv2=tlib.Con2D_transpose(h1,[nums,14,14,FLAGS.DIM],5,2,scope="conv2D_transpose2")

        h2= tf.nn.relu(dconv2)

        dconv3 = tlib.Con2D_transpose(h2,[nums,28,28,FLAGS.input_channel],5,2,scope="conv2D_transpose3")

        h3 = tf.nn.sigmoid(dconv3)

    return tf.reshape(h3,[-1,FLAGS.Out_DIm])