# 1. 通过TensorFlow-Slim定义卷机神经网络 import numpy as np import tensorflow as tf import tensorflow.contrib.slim as slim from tensorflow.examples.tutorials.mnist import input_data # 通过TensorFlow-Slim来定义LeNet-5的网络结构. def lenet5(inputs): inputs = tf.reshape(in…
# 1. 通过TFLearn的API定义卷机神经网络. import tflearn import tflearn.datasets.mnist as mnist from tflearn.layers.conv import conv_2d, max_pool_2d from tflearn.layers.estimator import regression from tflearn.layers.core import input_data, dropout, fully_connecte…
import numpy as np import tensorflow as tf import matplotlib.pyplot as plt #读取图片 image_raw_data = tf.gfile.FastGFile("F:\\TensorFlowGoogle\\201806-github\\datasets\\cat.jpg",'rb').read() with tf.Session() as sess: img_data = tf.image.decode_jpeg…
# 1. 自定义模型并训练. import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data tf.logging.set_verbosity(tf.logging.INFO) def lenet(x, is_training): x = tf.reshape(x, shape=[-1, 28, 28, 1]) conv1 = tf.layers.conv2…
# 1. 模型定义. import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data tf.logging.set_verbosity(tf.logging.INFO) mnist = input_data.read_data_sets("F:\\TensorFlowGoogle\\201806-github\\datasets\\MNIST_data&qu…
# 1. 模型定义. import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist_data = input_data.read_data_sets('F:\\TensorFlowGoogle\\201806-github\\datasets\\MNIST_data', one_hot=True) # 通过TensorFlow中的placeholder定义输入. x = tf.pl…
import tensorflow as tf import numpy as np ''' 初始化运算图,它包含了上节提到的各个运算单元,它将为W,x,b,h构造运算部件,并将它们连接 起来 ''' graph = tf.Graph() #一次tensorflow代码的运行都要初始化一个session session = tf.InteractiveSession(graph=graph) ''' 我们定义三种变量,一种叫placeholder,它对应输入变量,也就是上节计算图所示的圆圈部分,…
import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data 1.在自己编译器运行的python环境的...\Python3\Lib\site-packages,该目录下有文件夹tensorflow, tensorflow_core, ensorflow_estimator 2.进入tensorflow_core\examples文件夹,如果文件夹下只有s…
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模型. import tensorflow.contrib.slim.python.slim.nets.incepti…
Matplotlib 是 Python 的绘图库. 它可与 NumPy 一起使用,提供了一种有效的 MatLab 开源替代方案. 它也可以和图形工具包一起使用,如 PyQt 和 wxPython. Windows 系统安装 Matplotlib 进入到 cmd 窗口下,执行以下命令: python -m pip install -U pip setuptools python -m pip install matplotlib Linux 系统安装 Matplotlib 可以使用 Linux 包…