资源简介
mnist inception score实例
代码片段和文件信息
import gzip
import os
GPUID = 1
os.environ[“CUDA_VISIBLE_DEVICES“] = str(GPUID)
from scipy import ndimage
from six.moves import urllib
import numpy as np
import tensorflow as tf
import tensorflow.contrib.slim as slim
import math
import sys
import scipy.io
import pdb
print (“PACKAGES LOADED“)
def CNN(inputs _is_training=True):
x = tf.reshape(inputs [-1 28 28 1])
batch_norm_params = {‘is_training‘: _is_training ‘decay‘: 0.9 ‘updates_collections‘: None}
net = slim.conv2d(x 32 [5 5] padding=‘SAME‘
activation_fn = tf.nn.relu
weights_initializer = tf.truncated_normal_initializer(stddev=0.01)
normalizer_fn = slim.batch_norm
normalizer_params = batch_norm_params
scope=‘conv1‘)
net = slim.max_pool2d(net [2 2] scope=‘pool1‘)
net = slim.conv2d(net 64 [5 5] scope=‘conv2‘)
net = slim.max_pool2d(net [2 2] scope=‘pool2‘)
net = slim.flatten(net scope=‘flatten3‘)
net = slim.fully_connected(net 1024
activation_fn = tf.nn.relu
weights_initializer = tf.truncated_normal_initializer(stddev=0.01)
normalizer_fn = slim.batch_norm
normalizer_params = batch_norm_params
scope=‘fc4‘)
net = slim.dropout(net keep_prob=0.7 is_training=_is_training scope=‘dropout4‘)
out = slim.fully_connected(net 10 activation_fn=None normalizer_fn=None scope=‘fco‘)
return out
# DATA URL
SOURCE_URL = ‘http://yann.lecun.com/exdb/mnist/‘
DATA_DIRECTORY = “data“
# PARAMETERS FOR MNIST
IMAGE_SIZE = 28
NUM_CHANNELS = 1
PIXEL_DEPTH = 255
NUM_LABELS = 10
VALIDATION_SIZE = 5000 # Size of the validation set.
# DOWNLOAD MNIST DATA IF NECESSARY
def maybe_download(filename):
if not tf.gfile.Exists(DATA_DIRECTORY):
tf.gfile.MakeDirs(DATA_DIRECTORY)
filepath = os.path.join(DATA_DIRECTORY filename)
if not tf.gfile.Exists(filepath):
filepath _ = urllib.request.urlretrieve(SOURCE_URL + filename filepath)
with tf.gfile.GFile(filepath) as f:
size = f.size()
print(‘Successfully downloaded‘ filename size ‘bytes.‘)
return filepath
# EXTRACT IMAGES
def extract_data(filename num_images):
with gzip.open(filename) as bytestream:
bytestream.read(16)
buf = bytestream.read(IMAGE_SIZE * IMAGE_SIZE * num_images * NUM_CHANNELS)
data = np.frombuffer(buf dtype=np.uint8).astype(np.float32)
data = (data - (PIXEL_DEPTH / 2.0)) / PIXEL_DEPTH # -0.5~0.5
data = data.reshape(num_images IMAGE_SIZE IMAGE_SIZE NUM_CHANNELS)
data = np.reshape(data [num_images -1])
return data # [image index y x channels]
# EXTRACT LABELS
def extract_labels(filename num_images):
with gzip.open(filename) as bytestream:
bytestream.read(8)
buf = by
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-24 02:18 MNIST_Inception_Score-master\
文件 17 2017-11-24 02:18 MNIST_Inception_Score-master\.gitignore
文件 1943 2017-11-24 02:18 MNIST_Inception_Score-master\README.md
文件 12427 2017-11-24 02:18 MNIST_Inception_Score-master\icp_plot.pdf
文件 8935 2017-11-24 02:18 MNIST_Inception_Score-master\mnist_cnn_icp_eval.py
文件 10543 2017-11-24 02:18 MNIST_Inception_Score-master\mnist_cnn_train_slim.py
文件 652 2017-11-24 02:18 MNIST_Inception_Score-master\mnist_icp_plot.py
目录 0 2017-11-24 02:18 MNIST_Inception_Score-master\model\
文件 77 2017-11-24 02:18 MNIST_Inception_Score-master\model\checkpoint
文件 39304068 2017-11-24 02:18 MNIST_Inception_Score-master\model\model.ckpt.data-00000-of-00001
文件 1131 2017-11-24 02:18 MNIST_Inception_Score-master\model\model.ckpt.index
文件 274516 2017-11-24 02:18 MNIST_Inception_Score-master\model\model.ckpt.me
- 上一篇:jli
nk V9驱动 - 下一篇:vs2010串口发送接收程序
相关资源
- AIR-AP1830-K9-ME-8-3-143-0.tar
- 使用attention+GAN网络输入文本生成和文
- Markov Decision Processes Discrete Stochastic
- Altium原理图库,主要是DSP的SCH
- MSC.MARC在材料加工工程中的应用.PDF
- PSCAD 4.2 Pro 破解版
- LabWindowsCVI虚拟仪器测试技术及工程应
- Acunetix wvs 11含破解.rar
- 西门子SCL编程软件支持win7——V5.5
- Hands-On Machine Learning with Scikit-Learn an
- Hands-On Machine Learning with Scikit-Learn an
- spark-Scala编程中文版(33章全).pdf
- cisco转华为命令翻译
- 约翰·斯科特John Scott着;刘军译_社会
- PSCAD建模与仿真__李学生主编_北京:中
- OpenSceneGraphReferenceDocs-3.4.0.chm
- Ultrascope for DS1000E Series
- 嵌入式系统——采用公开源代码和S
- Scala Machine Learning ProjectsScala机器学习
- NVIDIA高级SSAO环境遮蔽算法SAmbient Obs
- Scratch教案完整版165377
- c2960x-universalk9-mz.152-2.E7.bin
- cisco packet tracer 5.3.3
-
Actionsc
ript 3.0游戏编程第2版 - scifinder scholar
- (全网首发) Computer Organization and A
- SCI写作资料合集
- CUCM实施文档
- Writing Scientific Research Articles
- MMC模块化多电平变换器全套资料+PSC
评论
共有 条评论