예제 #1
0
def Discriminator(input, reuse=False):
    with tf.variable_scope("Discriminator") as scope:
        if reuse:
            scope.reuse_variables()
        image = tf.reshape(input, [-1, 28, 28, 1])

        conv1 = tlib.Con2D(image, FLAGS.DIM, 5, 2, scope="conv1")

        relu1 = tlib.leaky_relu(conv1)

        conv2 = tlib.Con2D(relu1, 2 * FLAGS.DIM, 5, 2, scope="conv2")

        relu2 = tlib.leaky_relu(conv2)

        conv3 = tlib.Con2D(relu2, 4 * FLAGS.DIM, 5, 2, scope="conv3")

        relu3 = tlib.leaky_relu(conv3)

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

        fc1_source = tlib.fc(out_put, 1, scope="fc1")

        fc2_class = tlib.fc(out_put, FLAGS.n_class, scope="fc2")

        fc3_con = tlib.fc(out_put, 2, scope="fc3")

        n_class_ = tf.nn.softmax(fc2_class, name="class")

    return fc1_source, fc2_class, fc3_con, n_class_
예제 #2
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])
예제 #3
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])
예제 #4
0
def Discriminator_k(input, reuse=False):
    with tf.variable_scope("Discriminator") as scope:
        if reuse:
            scope.reuse_variables()
        #image = tf.transpose(tf.reshape(input,[-1,3,32,32]),perm=[0,2,3,1])
        conv1 = tlib.Con2D(input, FLAGS.DIM, 5, 2, scope="conv1")
        relu1 = tlib.leaky_relu(conv1)
        conv2 = tlib.Con2D(relu1, 2 * FLAGS.DIM, 5, 2, scope="conv2")
        relu2 = tlib.leaky_relu(conv2)
        conv3 = tlib.Con2D(relu2, 4 * FLAGS.DIM, 5, 2, scope="conv3")
        relu3 = tlib.leaky_relu(conv3)
        out_put = tf.reshape(relu3, [-1, 4 * 4 * 4 * FLAGS.DIM])
        fc1 = tlib.fc(out_put, 1, scope="fc1")
    return tf.reshape(fc1, [-1])
예제 #5
0
def Discriminator(input, reuse=False):
    with tf.variable_scope("Discriminator") as scope:
        if reuse:
            scope.reuse_variables()
        image = tf.reshape(input, [-1, 28, 28, 1])

        conv1 = tlib.Con2D(image, FLAGS.DIM, 5, 2, scope="conv1")

        relu1 = tlib.leaky_relu(conv1)

        conv2 = tlib.Con2D(relu1, 2 * FLAGS.DIM, 5, 2, scope="conv2")

        relu2 = tlib.leaky_relu(conv2)

        conv3 = tlib.Con2D(relu2, 4 * FLAGS.DIM, 5, 2, scope="conv3")

        relu3 = tlib.leaky_relu(conv3)

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

        fc1 = tlib.fc(out_put, 1, scope="fc1")

    return fc1