![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
TensorFlow
痴迷、淡然~
Life is 10% what happens to you and 90% how you react to it.
展开
-
Python3.7安装Tensorflow(CPU、Windows版)
Python3.7安装Tensorflow(CPU、Windows版)环境:下载安装的 Anaconda3-5.3.1-Windows-x86_64,对应的 Python3.7 版本系统:Windows10安装步骤:1. cmd窗口下:pip install tensorflow报错:ERROR: tensorboard 1.14.0 has requirement set...原创 2019-08-21 20:00:26 · 7395 阅读 · 2 评论 -
tf.constant()函数介绍和示例
tf.constant()函数介绍和示例tf.constant(value, shape, dtype=None, name=None)释义:生成常量value,值shape,数据形状dtype,数据类型name,名称示例:import tensorflow as tf c = tf.constant(-1, shape=[2,3], dtype=tf.float32, n...原创 2019-09-07 15:56:56 · 4629 阅读 · 0 评论 -
tf.equal()函数介绍和示例
tf.equal()函数介绍和示例tf.equal(A, B, name=None)释义:对比 A,B 矩阵或向量的元素,若相等则返回True,否则返回False注意:不同数据类型比较会报错,需要转换为相同数据类型进行比较示例:import tensorflow as tfX = tf.constant([1.,2.,3.,4.,5.,6.], dtype=tf.float32)Y...原创 2019-09-07 15:57:31 · 1189 阅读 · 0 评论 -
tf.transpose()函数介绍和示例
tf.transpose()函数介绍和示例tf.transpose(X, perm=None, name=‘transpose’, conjugate=False)释义:交换维度X:需要变换的张量perm:新的维度序列name:(可选)操作名称conjugate:(可选),设置为True,等价于 tf.conj(tf.transpose()),为维度倒序交换,且共轭示例1:二维...原创 2019-09-07 15:58:21 · 936 阅读 · 0 评论 -
tf.stack()、tf.unstack()函数介绍和示例
tf.stack()、tf.unstack()函数介绍和示例1. tf.stack([A, B] axis=0)释义:矩阵拼接A,B,输入张量axis,指定拼接维度,默认为0。示例1:二维数据中,维度 0 处拼接import tensorflow as tf A = [[1, 2, 3], [4, 5, 6]]B = [[10, 20, 30], [4...原创 2019-09-07 15:59:33 · 1885 阅读 · 0 评论 -
tf.multiply()、tf.matmul()、tf.scalar_mul()函数介绍和示例
tf.multiply()、tf.matmul()、tf.scalar_mul()函数介绍和示例1. tf.multiply()释义:将两个矩阵中对应元素各自相乘示例:import tensorflow as tfX = tf.constant([[1, 2, 3], [4, 5 ,6]], dtype=tf.float32, name=None)Y = tf.constant([[...原创 2019-09-07 16:02:33 · 4905 阅读 · 0 评论 -
tf.add()、tf.subtract()、tf.multiply()、tf.div()函数介绍和示例
tf.add()、tf.subtract()、tf.multiply()、tf.div()函数介绍和示例1. tf.add()释义:加法操作示例:x = tf.constant(2, dtype=tf.float32, name=None)y = tf.constant(3, dtype=tf.float32, name=None)z = tf.add(x, y) # ...原创 2019-09-07 16:09:53 · 6340 阅读 · 1 评论 -
tf.reduce_mean()函数、reduction_indices参数介绍和示例以及tf.reduce_sum()、tf.reduce_max()系列函数介绍
tf.reduce_mean()函数、reduction_indices参数介绍和示例以及tf.reduce_sum()、tf.reduce_max()系列函数介绍1. tf.reduce_mean(input_tensor, axis=None, keep_dims=False, name=None)释义:指定维度求均值,默认求所有元素均值input_tesor,输入张量axis,指定...原创 2019-09-07 16:12:10 · 2118 阅读 · 0 评论 -
tf.reshape()函数介绍和示例
tf.reshape()函数介绍和示例tf.reshape(tensor, shape, name=None)释义:将张量 tensor 的形状改为 shape注意:shape 设置为 -1 的位置,表示不用设置这一维的大小,函数自动进行计算(只能存在一个 -1)示例1:import tensorflow as tfX = tf.constant([[1, 2, 3], [4, 5,...原创 2019-09-07 16:12:52 · 1980 阅读 · 0 评论 -
tf.concat()函数介绍和示例
tf.concat()函数介绍和示例tf.concat([tensor1, tensor2, tensor3, … ], axis)释义:将张量 tensor1, tensor2, tensor3, … 拼接axis,指定轴(维度)示例:import tensorflow as tft1 = tf.constant([[1, 2, 3], [4, 5, 6]], dtype=tf...原创 2019-09-07 16:13:37 · 956 阅读 · 0 评论 -
tf.square()、tf.pow()、tf.math.pow()函数介绍和示例
tf.square()、tf.pow()、tf.math.pow()函数介绍和示例1. tf.square()释义:对各元素求平方示例:import tensorflow as tfX = tf.constant([1, 2, 3, 4], dtype=tf.float32, name=None)Y = tf.square(X) # 平方操作with tf.Ses...原创 2019-09-07 16:23:30 · 17965 阅读 · 0 评论 -
tf.truncated_normal()函数介绍和示例
tf.truncated_normal()函数介绍和示例tf.truncated_normal(shape, mean, stddev)释义:截断的产生正态分布的随机数,即随机数与均值的差值若大于两倍的标准差,则重新生成。shape,生成张量的维度mean,均值stddev,标准差示例:import tensorflow as tf c = tf.truncated_norm...原创 2019-09-07 15:56:18 · 34957 阅读 · 0 评论 -
tf.cast()函数介绍和示例
tf.cast()函数介绍和示例tf.cast(x, dtype, name=None)释义:数据类型转换x,输入张量dtype,转换数据类型name,名称示例:import tensorflow as tfX = tf.constant([1,2,3,4,5], dtype=tf.int32)Y = tf.cast(X, dtype=tf.float32)with t...原创 2019-09-07 15:55:32 · 16916 阅读 · 0 评论 -
TensorFlow报错:InvalidArgumentError: You must feed a value for placeholder tensor 'inputs/y_input'
Jupyter Notebook 中使用 TensorFlow 构建神经网络时,通过 tensotboard 可视化数据变化趋势,run tf.summary.merge_all() 操作时报错:InvalidArgumentError: You must feed a value for placeholder tensor ‘inputs/y_input’ with dtype floa...原创 2019-08-22 21:37:43 · 3169 阅读 · 0 评论 -
TensorFlow报错:AttributeError: module 'tensorflow._api.v1.train' has no attribute 'SummaryWriter'等
TensorFlow报错:AttributeError: module ‘tensorflow._api.v1.train’ has no attribute 'SummaryWriter’等分析:版本更新,方法调用方式改变解决方式:报错原方法更改后方法AttributeError: module ‘tensorflow._api.v1.train’ has no at...原创 2019-08-22 21:49:22 · 31512 阅读 · 1 评论 -
TensorBoard入门展示神经网络图信息,解决No graph definition files were found问题
TensorBoard入门展示神经网络图信息,解决No graph definition files were found问题使用 TensorFlow 构建神经网络,并将图信息保存在当前目录的 logs 文件目录下:import tensorflow as tfimport numpy as npdef add_layer(inputs, in_size, out_size, acti...原创 2019-08-22 22:03:10 · 427 阅读 · 0 评论 -
TensorFlow报错:InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_2' with
TensorFlow报错:InvalidArgumentError: You must feed a value for placeholder tensor ‘Placeholder_2’ with dtype float如图:InvalidArgumentError: You must feed a value for placeholder tensor ‘Placeholder_2...原创 2019-09-03 21:53:30 · 17120 阅读 · 1 评论 -
TensorFlow报错:NotFoundError: Key weights not found in checkpoint
TensorFlow报错:NotFoundError: Key weights not found in checkpoint如图:NotFoundError: Key weights not found in checkpoint[[{{node save/RestoreV2}}]]分析:Tensorflow 保存时需要注意以下几点,设定数据类型设定参数名称,打开时参数名称要...原创 2019-09-04 21:19:01 · 2368 阅读 · 1 评论 -
TensorFlow报错:AttributeError: module 'tensorflow' has no attribute 'unpack' (‘pack’)
TensorFlow报错:AttributeError: module ‘tensorflow’ has no attribute ‘unpack’ (‘pack’)如图:AttributeError: module ‘tensorflow’ has no attribute ‘unpack’分析:Tensorflow1.0+版本更新后,方法名变更解决方式:报错更新前更...原创 2019-09-04 21:21:09 · 3943 阅读 · 0 评论 -
TensorFlow报错:ValueError: Only call ‘softmax_cross_entropy_with_logits’ with named arguments (labels=
TensorFlow报错:ValueError: Only call ‘softmax_cross_entropy_with_logits’ with named arguments (labels=…, logits=…, …)如图:ValueError: Only call `softmax_cross_entropy_with_logits` with named arguments...原创 2019-09-04 21:23:12 · 506 阅读 · 0 评论 -
TensorFlow报错:AttributeError: module 'tensorflow._api.v1.nn' has no attribute 'seq2seq'
TensorFlow报错:AttributeError: module ‘tensorflow._api.v1.nn’ has no attribute ‘seq2seq’如图:分析:TensorFlow 版本升级,方法调用更改解决方式:旧版更改为tf.nn.seq2seq.sequence_loss_by_example()tf.contrib.legacy_se...原创 2019-09-04 21:24:07 · 21362 阅读 · 3 评论 -
TensorFlow报错:TypeError: msr_error() got an unexpected keyword argument 'labels'
TensorFlow报错:TypeError: msr_error() got an unexpected keyword argument ‘labels’学习莫烦TsnsorFlow教程时,第 20.3 RNN lstm(regression 回归例子) 遇到的一个报错如下:TypeError: msr_error() got an unexpected keyword argumen...原创 2019-09-04 21:25:40 · 11537 阅读 · 2 评论 -
tf.argmax()函数介绍和示例
tf.argmax()函数介绍和示例tf.argmax(input_tensor, axis=0)释义:返回指定维度最大值的索引input_tensor,输入张量axis,指定维度,默认为0。二维情况下,若为0,则返回列数据最大值索引;若为1,则返回行数据最大值索引示例:import tensorflow as tfX = tf.constant([[1, 2, 3],...原创 2019-09-07 15:54:58 · 1367 阅读 · 1 评论 -
tf.assign()、tf.assign_add()、tf.assign_sub()函数介绍和示例
tf.assign()、tf.assign_add()、tf.assign_sub()函数介绍和示例1. tf.assign(ref, value, validate_shape=True, use_locking=None, name=None)释义:将 value 赋值给 ref,即 ref = valueref,变量value,值validate_shape,默认 True,值 ...原创 2019-09-08 10:17:39 · 12713 阅读 · 0 评论