GAN学习 | DCGAN TensorFlow代码解读(1):main.py

目录

main.py 代码解读

line11-30  封装外部传入的参数

tf.app.flags的理解

line33-48 定义主函数

pprint.PrettyPrinter() 的理解

 tf.ConfigProto() 的理解

line 33-105 主函数中定义session

小白总结

代码块学习


Github: DCGAN-Master

本文针对DCGAN的TensorFlow master代码进行解读,并针对MNIST手写数据进行实验。

main.py 代码解读

line1-8 import 库、import自己py文件中的函数和模型

import os
import scipy.misc
import numpy as np
import tensorflow as tf

# 从自定义的文件中import
from model import DCGAN
from utils import pp, visualize, to_json, show_all_variables

line11-30  封装外部传入的参数

flags = tf.app.flags  # 外部参数传递
flags.DEFINE_integer("epoch", 25, "Epoch to train [25]")
flags.DEFINE_float("learning_rate", 0.0002, "Learning rate of for adam [0.0002]")
flags.DEFINE_float("beta1", 0.5, "Momentum term of adam [0.5]")
flags.DEFINE_float("train_size", np.inf, "The size of train images [np.inf]")  # np.inf??
flags.DEFINE_integer("batch_size", 64, "The size of batch images [64]")
flags.DEFINE_integer("input_height", 108, "The size of image to use (will be center cropped). [108]")
flags.DEFINE_integer("input_width", None, "The size of image to use (will be center cropped). If None, same value as input_height [None]")
flags.DEFINE_integer("output_height", 64, "The size of the output images to produce [64]")
flags.DEFINE_integer("output_width", None, "The size of the output images to produce. If None, same value as output_height [None]")
flags.DEFINE_string("dataset", "mnist", "The name of dataset [c
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值