看到一个有意思的代码网页!!!!泡妹子的代码!!!

下载代码:下载代码https://download.csdn.net/download/qq_42867062/10584624
这里写图片描述
代码如下:



Our Love Story


@font-face {
font-family: digit;
src: url(‘digital-7_mono.ttf’) format(“truetype”);
}









/**

* We are both Fudan SSers and programmers,

* so I write some code to celebrate our 1st anniversary.

*/

Boy i = new Boy(“hackerzhou”);

Girl u = new Girl(“MaryNee”);

// Nov 2, 2010, I told you I love you.

i.love(u);

// Luckily, you accepted and became my girlfriend eversince.

u.accepted();

// Since then, I miss u every day.

i.miss(u);

// And take care of u and our love.

i.takeCareOf(u);

// You say that you won’t be so easy to marry me.

// So I keep waiting and I have confidence that you will.

boolean isHesitate = true;

while (isHesitate) {

i.waitFor(u);

// I think it is an important decision

// and you should think it over.

isHesitate = u.thinkOver();

}

// After a romantic wedding, we will live happily ever after.

i.marry(u);

i.liveHappilyWith(u);






Minyue, I have fallen in love with you for



Love u forever and ever.

- hackerzhou






  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
这里提供一个简单的GAN训练生成二次元妹子代码,需要使用Python和Tensorflow库: ```python import tensorflow as tf import numpy as np import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/") # 定义生成器网络 def generator(z, reuse=None): with tf.variable_scope('gen', reuse=reuse): hidden1 = tf.layers.dense(inputs=z, units=128) alpha = 0.01 hidden1 = tf.maximum(alpha * hidden1, hidden1) hidden2 = tf.layers.dense(inputs=hidden1, units=128) hidden2 = tf.maximum(alpha * hidden2, hidden2) output = tf.layers.dense(inputs=hidden2, units=784, activation=tf.nn.tanh) return output # 定义判别器网络 def discriminator(X, reuse=None): with tf.variable_scope('dis', reuse=reuse): hidden1 = tf.layers.dense(inputs=X, units=128) alpha = 0.01 hidden1 = tf.maximum(alpha * hidden1, hidden1) hidden2 = tf.layers.dense(inputs=hidden1, units=128) hidden2 = tf.maximum(alpha * hidden2, hidden2) logits = tf.layers.dense(hidden2, units=1) output = tf.sigmoid(logits) return output, logits # 定义输入占位符 real_images = tf.placeholder(tf.float32, shape=[None, 784]) z = tf.placeholder(tf.float32, shape=[None, 100]) # 定义损失函数 G = generator(z) D_output_real, D_logits_real = discriminator(real_images) D_output_fake, D_logits_fake = discriminator(G, reuse=True) def loss_func(logits_in, labels_in): return tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=logits_in, labels=labels_in)) D_real_loss = loss_func(D_logits_real, tf.ones_like(D_logits_real) * 0.9) # 平滑标签 D_fake_loss = loss_func(D_logits_fake, tf.zeros_like(D_logits_real)) D_loss = D_real_loss + D_fake_loss G_loss = loss_func(D_logits_fake, tf.ones_like(D_logits_fake)) # 定义优化器 lr = 0.001 tvars = tf.trainable_variables() d_vars = [var for var in tvars if 'dis' in var.name] g_vars = [var for var in tvars if 'gen' in var.name] D_trainer = tf.train.AdamOptimizer(lr).minimize(D_loss, var_list=d_vars) G_trainer = tf.train.AdamOptimizer(lr).minimize(G_loss, var_list=g_vars) # 训练模型 batch_size = 100 epochs = 500 init = tf.global_variables_initializer() samples = [] with tf.Session() as sess: sess.run(init) for epoch in range(epochs): num_batches = mnist.train.num_examples // batch_size for i in range(num_batches): batch = mnist.train.next_batch(batch_size) batch_images = batch[0].reshape((batch_size, 784)) batch_images = batch_images * 2 - 1 # 将像素值调整到[-1, 1]区间 batch_z = np.random.uniform(-1, 1, size=(batch_size, 100)) _ = sess.run(D_trainer, feed_dict={real_images: batch_images, z: batch_z}) _ = sess.run(G_trainer, feed_dict={z: batch_z}) print("Epoch: {}/{}".format(epoch+1, epochs)) # 每10个epoch保存一次生成的样本 sample_z = np.random.uniform(-1, 1, size=(1, 100)) gen_sample = sess.run(generator(z, reuse=True), feed_dict={z: sample_z}) samples.append(gen_sample) # 显示生成的图片 plt.imshow(samples[0].reshape(28,28), cmap='Greys') plt.show() ``` 该代码使用了MNIST数据集作为训练数据,生成器和判别器的结构均为两层全连接层,使用了Adam优化器。生成器的输入是随机噪声,输出是28x28像素的二次元妹子图片。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值