• 大小: 34.74MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-11
  • 语言: 其他
  • 标签: inception  sc  GAN  

资源简介

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.meta

评论

共有 条评论