首页
Python
Java
IOS
Andorid
NodeJS
JavaScript
HTML5
【
吴裕雄 python 神经网络——TensorFlow TFRecord样例程序
】的更多相关文章
吴裕雄 python 神经网络——TensorFlow TFRecord样例程序
import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # 定义函数转化变量类型. def _int64_feature(value): return tf.train.Feature(int64_list=tf.train.Int64List(value=[value])) def _bytes_feature(value): return tf.…
吴裕雄 python 神经网络TensorFlow实现LeNet模型处理手写数字识别MNIST数据集
import tensorflow as tf tf.reset_default_graph() # 配置神经网络的参数 INPUT_NODE = 784 OUTPUT_NODE = 10 IMAGE_SIZE = 28 NUM_CHANNELS = 1 NUM_LABELS = 10 # 第一层卷积层的尺寸和深度 CONV1_DEEP = 32 CONV1_SIZE = 5 # 第二层卷积层的尺寸和深度 CONV2_DEEP = 64 CONV2_SIZE = 5 # 全连接层的节点个数 FC…
吴裕雄 python 神经网络——TensorFlow 输入数据处理框架
import tensorflow as tf files = tf.train.match_filenames_once("E:\\MNIST_data\\output.tfrecords") filename_queue = tf.train.string_input_producer(files, shuffle=False) # 读取文件. reader = tf.TFRecordReader() _,serialized_example = reader.read(filen…
吴裕雄 python 神经网络——TensorFlow 输入文件队列
import tensorflow as tf def _int64_feature(value): return tf.train.Feature(int64_list=tf.train.Int64List(value=[value])) num_shards = 2 instances_per_shard = 2 for i in range(num_shards): filename = ('E:\\temp\\data.tfrecords-%.5d-of-%.5d' % (i, num_…
吴裕雄 python 神经网络——TensorFlow 图像预处理完整样例
import numpy as np import tensorflow as tf import matplotlib.pyplot as plt def distort_color(image, color_ordering=0): if color_ordering == 0: image = tf.image.random_brightness(image, max_delta=32./255.) image = tf.image.random_saturation(image, low…
吴裕雄 python 神经网络——TensorFlow 完整神经网络样例程序
import tensorflow as tf from numpy.random import RandomState batch_size = 8 w1= tf.Variable(tf.random_normal([2, 3], stddev=1, seed=1)) w2= tf.Variable(tf.random_normal([3, 1], stddev=1, seed=1)) x = tf.placeholder(tf.float32, shape=(None, 2), name="…
吴裕雄 python 神经网络——TensorFlow variables_to_restore函数的使用样例
import tensorflow as tf v = tf.Variable(0, dtype=tf.float32, name="v") ema = tf.train.ExponentialMovingAverage(0.99) print(ema.variables_to_restore()) saver = tf.train.Saver({"v/ExponentialMovingAverage": v}) with tf.Session() as sess:…
吴裕雄 python 神经网络——TensorFlow训练神经网络:卷积层、池化层样例
import numpy as np import tensorflow as tf M = np.array([ [[1],[-1],[0]], [[-1],[2],[1]], [[0],[2],[-2]] ]) print("Matrix shape is: ",M.shape) filter_weight = tf.get_variable('weights', [2, 2, 1, 1], initializer = tf.constant_initializer([[1, -1…
吴裕雄 python 神经网络——TensorFlow 数据集高层操作
import tempfile import tensorflow as tf train_files = tf.train.match_filenames_once("E:\\output.tfrecords") test_files = tf.train.match_filenames_once("E:\\output_test.tfrecords") # 解析一个TFRecord的方法. def parser(record): features = tf.pa…
吴裕雄 python 神经网络——TensorFlow 数据集基本使用方法
import tempfile import tensorflow as tf input_data = [1, 2, 3, 5, 8] dataset = tf.data.Dataset.from_tensor_slices(input_data) # 定义迭代器. iterator = dataset.make_one_shot_iterator() # get_next() 返回代表一个输入数据的张量. x = iterator.get_next() y = x * x with tf.S…