![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
TensorFlow
Sam Chou
这个作者很懒,什么都没留下…
展开
-
TensorFlow——卷积神经网络(三)
1、tf.layers.conv2dimport tensorflow as tf# 设置输入形状为[1,5,5,1] 的随机矩阵input = tf.Variable(tf.random_normal([1, 5, 5, 1]))# 步长为 1 的卷积操作,一个选择'VALID'方式填充一个选择'SAME'方式填充same_conv2d_s1 = tf.layers.conv2d(input, filters=1, kernel_size=3, strides=1, padding='S原创 2020-10-11 20:20:48 · 179 阅读 · 0 评论 -
TensorFlow——卷积神经网络(二)
1、卷积import cv2import numpy as npimport tensorflow as tf# 读入灰度图片img = cv2.imread('./img/Lenna.jpg', 0)# 显示原图cv2.imshow('yuantu', img)# 设置不同卷积核初值# kernel = np.array(([-1, -1, -1], [-1, 9, -1], [-1, -1, -1]), dtype=np.float32)# kernel = np.array原创 2020-10-04 13:18:39 · 126 阅读 · 0 评论 -
TensorFlow——TensorBoard应用进阶
1、TensorBoard1import tensorflow as tfimport tensorflow.examples.tutorials.mnist.input_data as input_datamnist = input_data.read_data_sets("MNIST_data/", one_hot=True)x = tf.placeholder(tf.float32, [None, 784])y_actual = tf.placeholder(tf.float32,原创 2020-09-29 16:06:05 · 135 阅读 · 0 评论 -
TensorFlow——模型保存与使用
1、ckpt_saveimport tensorflow as tfimport tensorflow.examples.tutorials.mnist.input_data as input_datamnist = input_data.read_data_sets("MNIST_data/", one_hot=True)x = tf.placeholder(tf.float32, [None, 784], name='input')y_actual = tf.placeholder(t原创 2020-09-29 11:45:08 · 605 阅读 · 0 评论 -
TensorFlow——神经网络参数优化
1、backward# conding:utf-8import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_dataimport mnist_forwsrdimport osBATCH_SIZE = 200LEARNING_RATE_BASE = 0.1LEARNING_RATE_DECAY = 0.99REGULARIZER = 0.0001STEPS = 100000MOVING_原创 2020-09-29 11:33:24 · 303 阅读 · 0 评论 -
TensorFlow——全连接神经网络识别手写数字(二)
1、Randomimport tensorflow as tfx = tf.random_uniform([10, ], minval=-1, maxval=1)with tf.Session() as sess: init = tf.global_variables_initializer() sess.run(init) print('x:', sess.run(x))2、ReLUimport tensorflow as tfx = [-5., 0.原创 2020-09-29 11:02:15 · 124 阅读 · 0 评论 -
TensorFlow——全连接神经网络识别手写数字(一)
1、MINISTimport tensorflow as tfimport tensorflow.examples.tutorials.mnist.input_data as input_datamnist = input_data.read_data_sets("MNIST_data/", one_hot=True)x = tf.placeholder(tf.float32, [None, 784])y_actual = tf.placeholder(tf.float32, [None,原创 2020-09-29 10:23:56 · 228 阅读 · 0 评论 -
TensorFlow——MNIST手写数字数据集
1、np_mnist_readimport structimport numpy as npimport matplotlib.pyplot as pltdef read_image_files(filename, num): bin_file = open(filename, 'rb') buf = bin_file.read() index = 0 # # 读取前四个数字 # magic, numImage, numRows, numCols =原创 2020-09-29 10:15:32 · 303 阅读 · 0 评论 -
TensorFlow——神经网络分类异或问题
1、sigmoidimport tensorflow as tfimport numpy as npnp.set_printoptions(suppress=True)# # 与# x = [10., -10., -10., -30.]# # 或# x = [30., 10., 10., -10.]# 非x = [-10., 10.]A = tf.sigmoid(x)with tf.Session() as sess: print(sess.run(A))...原创 2020-09-29 10:02:17 · 217 阅读 · 0 评论 -
TensorFlow——神经网络非线性回归
1、非线性回归import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt# 使用numpy 生成200个随机点,范围在-0.5--0.5之间,产生了200行1列的矩阵# newaxis = Nonex_data = np.linspace(-0.5, 0.5, 200)[:, np.newaxis]# 产生随机噪声noise = np.random.normal(0, 0.01, x_data.sh原创 2020-09-29 09:54:20 · 451 阅读 · 0 评论 -
TensorFlow——神经网络多元线性回归
1、多元线性回归""" CRIM 城镇人均犯罪率 ZN 占地面积超过2.5万平方英尺的住宅用地比例 INDUS 城镇非零售业务地区的比例 CHAS 查尔斯河虚拟变量 (= 1 如果土地在河边;否则是0) NOX 一氧化氮浓度(每千万) RM 平均每居民房数 AGE 在1940年之前建成的所有者占用单位的比例 DIS 与五个波士顿就业中心的加权距离 RAD 辐射状公路的可达性指数 TAX原创 2020-09-29 09:48:21 · 2123 阅读 · 0 评论 -
TensorFlow——神经网络一元线性回归
1、一元线性回归import tensorflow as tfimport matplotlib.pyplot as pltimport numpy as npa = 2 # 权重b = 1.5 # 偏置# 设置随机种子np.random.seed(5)# 生成100个点,区间为-1到1x_data = np.linspace(-1, 1, 100)# y = x_data * a + b + 噪声y_data = a * x_data + b + np.random.原创 2020-09-29 09:39:32 · 605 阅读 · 0 评论 -
TensorFlow——TensorBoard可视化工具
1、tensorboard"-----------------矩阵相乘----------------"import tensorflow as tfwith tf.name_scope('graph') as scope: matrix1 = tf.constant([[3., 3.]], name='matrix1') matrix2 = tf.constant([[2.], [2.]], name='matrix2') product = tf.matmul(mat原创 2020-09-28 11:24:41 · 123 阅读 · 0 评论 -
TensorFlow——TensorFlow基本运算
1、Session实例import tensorflow as tf# 搭建计算图node1 = tf.constant(2.0, tf.float32, name='node1')node2 = tf.constant(3.0, tf.float32, name='node2')node3 = tf.add(node1, node2)'''使用Session的模式一'''sess = tf.Session() # 创建会话print('node3运算结果为:', sess.run原创 2020-09-28 11:03:07 · 346 阅读 · 0 评论 -
TensorFlow——TensorFlow基础概念
1、张量的形状# import tensorflow as tf## tensor = tf.constant([[[1, 1, 1], [2, 2, 2]],# [[3, 3, 3], [4, 4, 4]],# [[5, 5, 5], [6, 6, 6]]], tf.float32)# print(tensor)import tensorflow as tf# 创建不同形状的张量scalar =原创 2020-09-27 17:41:36 · 129 阅读 · 0 评论