资源简介
生成式对抗网络(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
- 下一篇:程序实现二体运动的龙格库塔法
相关资源
- 程序实现二体运动的龙格库塔法
- 非线性回归Python代码
- 卷积神经网络图像识别python代码pdf
- 关于吃豆人的游戏代码python
- 基于Python的离线Google地图操作实现
- Python+OpenCv项目代码
- Python实现高斯投影正反算
- 100行python代码 帮你实现同花顺A股下单
- 决策树算法的PPT与实现代码
- 用python实现sm2国密算法
- openmv颜色识别代码
- Morphological Snakes——改进版Geodestic a
- 面向对象的银行管理系统课程设计完
- 一些python自动化代码
- 棋盘覆盖图形界面python自带tkinter库实
- Python3.x+Pyqt5实现界面编程浏览网页
- 量化投资:以Python为工具,代码和数
- 离散点-蓝噪声采样python 实现
- 西电数据挖掘作业之利用Python编程实
- Python爬虫、Flask框架与ECharts实现数据
- 《机器学习实战》Python3代码
- 基于python的小游戏 含源代码
- 深度学习入门 基于python理论与实现
- 混合地理加权回归python实现代码
- Python-在特征金字塔网络FPN的Pytorch实现
- Python-PyTorch实时多人姿态估计项目的实
- Python-用PyTorch10实现FasterRCNN和MaskRCNN比
- Python-PyTorch对卷积CRF的参考实现
- Python-高效准确的EAST文本检测器的一个
- Python-pytorch实现的人脸检测和人脸识别
评论
共有 条评论