吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(2)
摘要:import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platform import gfile # 原始输入数据的目录,这个目录下有5个子目录,每个子目录底下保存这属于该 # 类别的所有图片。 INPUT_DATA = 'F:\\TensorFlowGoogle...
阅读全文
吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(1)
摘要:import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platform import gfile # 原始输入数据的目录,这个目录下有5个子目录,每个子目录底下保存这属于该 # 类别的所有图片。 INPUT_DATA = 'F:\\TensorFlowGoogle...
阅读全文
吴裕雄 python 神经网络——TensorFlow 实现LeNet-5模型处理MNIST手写数据集
摘要:import os import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data tf.reset_default_graph() INPUT_NODE = 784 OUTPUT_NODE = 10 IMAGE_SIZE = 28 NUM_CHANN...
阅读全文
吴裕雄 python 神经网络——TensorFlow 花瓣识别2
摘要:import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platform import gfile import tensorflow.contrib.slim as slim # 加载通过TensorFlow-Slim定义好的inception_v3模型。 imp...
阅读全文
吴裕雄 python 神经网络——TensorFlow训练神经网络:花瓣识别
摘要:import os import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platform import gfile # 原始输入数据的目录,这个目录下有5个子目录,每个子目录底下保存这属于该 # 类别的所有图片。 INPUT_DATA = 'F:\\Tensor...
阅读全文
吴裕雄 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_...
阅读全文
吴裕雄 python 神经网络——TensorFlow训练神经网络:MNIST最佳实践
摘要:import os import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 OUTPUT_NODE = 10 LAYER1_NODE = 500 def get_weight_variable(shape, regularizer): wei...
阅读全文
吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用滑动平均
摘要:import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 # 输入节点 OUTPUT_NODE = 10 # 输出节点 LAYER1_NODE = 500 # 隐藏层数 ...
阅读全文
吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用隐藏层
摘要:import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 # 输入节点 OUTPUT_NODE = 10 # 输出节点 BATCH_SIZE = 100 # 每次batch打包的样本个数 # 模型相关的参数 LE...
阅读全文
吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用激活函数
摘要:import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 # 输入节点 OUTPUT_NODE = 10 # 输出节点 LAYER1_NODE = 500 # 隐藏层数 ...
阅读全文
吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用指数衰减的学习率
摘要:import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 # 输入节点 OUTPUT_NODE = 10 # 输出节点 LAYER1_NODE = 500 # 隐藏层数 ...
阅读全文
吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用正则化
摘要:import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 # 输入节点 OUTPUT_NODE = 10 # 输出节点 LAYER1_NODE = 500 # 隐藏层数 ...
阅读全文
吴裕雄 python 神经网络——TensorFlow训练神经网络:全模型
摘要:import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 # 输入节点 OUTPUT_NODE = 10 # 输出节点 LAYER1_NODE = 500 # 隐藏层数 ...
阅读全文
吴裕雄 python 神经网络——TensorFlow pb文件保存方法
摘要:import tensorflow as tf from tensorflow.python.framework import graph_util v1 = tf.Variable(tf.constant(1.0, shape=[1]), name = "v1") v2 = tf.Variable(tf.constant(2.0, shape=[1]), name = "v2") resul...
阅读全文
吴裕雄 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/ExponentialMovingAv...
阅读全文
吴裕雄 python 神经网络——TensorFlow 滑动平均类的保存
摘要:import tensorflow as tf v = tf.Variable(0, dtype=tf.float32, name="v") for variables in tf.global_variables(): print(variables.name) ema = tf.train.ExponentialMovingAverage(0.99) maintain_...
阅读全文
吴裕雄 python 神经网络——TensorFlow ckpt文件保存方法
摘要:import tensorflow as tf v1 = tf.Variable(tf.random_normal([1], stddev=1, seed=1)) v2 = tf.Variable(tf.random_normal([1], stddev=1, seed=1)) result = v1 + v2 init_op = tf.global_variables_initialize...
阅读全文
吴裕雄 python 神经网络——TensorFlow 变量管理
摘要:import tensorflow as tf with tf.variable_scope("foo"): v = tf.get_variable("v", [1], initializer=tf.constant_initializer(1.0)) #with tf.variable_scope("foo"): # v = t...
阅读全文
吴裕雄 PYTHON 神经网络——TENSORFLOW MNIST读取数据
摘要:from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("E:\\datasets\\MNIST_data\\", one_hot=True) print("Training data size: ", mnist.train.num_examples) pri...
阅读全文
吴裕雄 PYTHON 神经网络——TENSORFLOW 滑动平均模型
摘要:import tensorflow as tf v1 = tf.Variable(0, dtype=tf.float32) step = tf.Variable(0, trainable=False) ema = tf.train.ExponentialMovingAverage(0.99, step) maintain_averages_op = ema.apply([v1]) with...
阅读全文