资源简介
生成式对抗网络(GAN, Generative Adversarial Networks )是一种深度学习模型,是近年来复杂分布上无监督学习最具前景的方法之一。
代码片段和文件信息
“““
Know more visit my Python tutorial page: https://morvanzhou.github.io/tutorials/
My Youtube Channel: https://www.youtube.com/user/MorvanZhou
Dependencies:
tensorflow: 1.1.0
matplotlib
numpy
“““
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
tf.set_random_seed(1)
np.random.seed(1)
# Hyper Parameters
BATCH_SIZE = 64
LR_G = 0.0001 # learning rate for generator
LR_D = 0.0001 # learning rate for discriminator
N_IDEAS = 5 # think of this as number of ideas for generating an art work (Generator)
ART_COMPONENTS = 15 # it could be total point G can draw in the canvas
PAINT_POINTS = np.vstack([np.linspace(-1 1 ART_COMPONENTS) for _ in range(BATCH_SIZE)])
# show our beautiful painting range
plt.plot(PAINT_POINTS[0] 2 * np.power(PAINT_POINTS[0] 2) + 1 c=‘#74BCFF‘ lw=3 label=‘upper bound‘)
plt.plot(PAINT_POINTS[0] 1 * np.power(PAINT_POINTS[0] 2) + 0 c=‘#FF9359‘ lw=3 label=‘lower bound‘)
plt.legend(loc=‘upper right‘)
plt.show()
def artist_works(): # painting from the famous artist (real target)
a = np.random.uniform(1 2 size=BATCH_SIZE)[: np.newaxis]
paintings = a * np.power(PAINT_POINTS 2) + (a-1)
return paintings
with tf.variable_scope(‘Generator‘):
G_in = tf.placeholder(tf.float32 [None N_IDEAS]) # random ideas (could from normal distribution)
G_l1 = tf.layers.dense(G_in 128 tf.nn.relu)
G_out = tf.layers.dense(G_l1 ART_COMPONENTS) # making a painting from these random ideas
with tf.variable_scope(‘Discriminator‘):
real_art = tf.placeholder(tf.float32 [None ART_COMPONENTS] name=‘real_in‘) # receive art work from the famous artist
D_l0 = tf.layers.dense(real_art 128 tf.nn.relu name=‘l‘)
prob_artist0 = tf.layers.dense(D_l0 1 tf.nn.sigmoid name=‘out‘) # probability that the art work
- 上一篇:python安装器easy_install
- 下一篇:程序实现二体运动的龙格库塔法
相关资源
- 7.图像风格迁移 基于深度学习 pyt
- A Byte of Python(简明Python教程)(第
- Python 人脸识别
- python实现自动操作windows应用
- pyqt5动态加载ui文件,动态加载背景图
- Widget控件轻松实现窗体镶嵌
- 简单实现tabWidget标签美化、拖动、关
- csv文件行列转换python实现代码
- django图片浏览+scrapy实现数据抓取功能
- 机器学习(周志华)配套代码
- python实现香农编码
- 酷喵浏览器 python代码
- 石头剪刀布python代码
- Python高級編程源代码
- 《PYTHON QT GUI快速编程 PYQT编程指南》
- 爬取百度图片到本地(python代码)
- 机器学习-岭回归实现
- python 画 金字塔代码
- python 重命名文件并排序
- 012345手势识别神经网络代码
- python 实现 屏幕水印
- 《大数据数学基础(Python语言描述)
- VGG16实现人脸检测
- numpy实现BP神经网络
- python实现 99乘法表
- 《Python 编程:从入门到实践》所有代
- 机器学习k means算法实现图像分割
- 帝国竞争算法python实现
- python实现逻辑回归
- python编程:入门到实践 源代码
评论
共有 条评论