tensorflow
hillyfighting
找方向,努力学习的羔羊。
展开
-
Tensorflow易错点(4)---tf.nn.sparse_softmax_cross_entropy_with_logits()函数的使用
tf.nn.sparse_softmax_cross_entropy_with_logits( labels, logits, name=None)参数解析:logits: 形状为[batch_size, num_classes], 数据类型必须为 float16,float32,float64。labels: 形状为[batch_size], 其元素的值必须在[0, num_classes)范围内, 数据类型为int32, int64。返回值:1-D Tensor。形状和 labe原创 2020-10-23 22:25:26 · 339 阅读 · 0 评论 -
Tensorflow易错点(3)---tf.FixedLenFeature的使用
看以下两种不同的shape,解析得到的tensor的shape不同:tf.FixedLenFeature(shape=[], dtype=tf.int64) # 解析得到的tensor的形状形如(bs, )tf.FixedLenFeature(shape=[k], dtype=tf.int64) # 解析得到的tensor的形状形如(bs,k )因此在解析样本数据时,特别要注意你要解析的tensor的形状,根据自己的需要填写k值。...原创 2020-10-22 23:31:39 · 3253 阅读 · 1 评论 -
Tensorflow易错点(1)---tensor的“只读“模式
在使用Encoder-Decoder机制解决文本识别问题时,我想要将Decoder端的每一时间步的预测prediction放入predictions中,让predictions能够记录全部时间步的prediction。假设prediction形如(N, ), 最大时间步为max_time_steps。首先说我使用的错误方式,predictions设为全0矩阵 ,大小为(N, max_time_steps), 之后再每个时间步给predictions赋值。代码如下# 方式1predictions原创 2020-10-21 23:31:36 · 133 阅读 · 0 评论 -
Tensorflow易错点(2)---多层RNN的定义
以RNN中的lstm为例:首先说一个普遍的错误方式,该方式会引起维数不匹配报错!# 错误方式!!!lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(num_units)stacked_lstm = tf.nn.rnn_cell.MultiRNNCell([lstm_cell for _ in range(layers_nums)])正确的多层lstm的定义lstm_cell = [tf.nn.rnn_cell.BasicLSTMCell(num_units) f原创 2020-10-21 22:56:38 · 352 阅读 · 0 评论 -
TensorFlow学习笔记(5)---TensorBoard可视化
TensorBoard是一种基于Web的TensorFlow可视化工具,可以有效的展示TensorFlow在运行过程中的计算图,各种指标随着时间变化的变化趋势以及训练过程中使用的图像信息。通过可视化tensorflow计算图以及可视化程序运行过程中的信息,便于调优。1. 生成日志文件在Session下,变量初始化前添加如下语句,则会生成日志文件writer = tf.summary.FileWriter(path/to/log)2. 日志文件写入2.1 往日志文件中添加TensorFlow计算原创 2020-08-08 22:49:23 · 192 阅读 · 1 评论 -
ubuntu18.04安装tensorflow-gpu==1.14.0(CUDA10.0+cuDNN7.4.1)
系统版本:ubuntu 18.04系统架构:x86_64nvidia driver 驱动版本:440.59CUDA版本:10.0cuDNN:7.4.1gcc:4.8.5tensorflow-gpu:1.14.0前提step1:确定是否安装了驱动:nvidia-smistep2:查看gcc版本:gcc --version若gcc版本太高就更改版本:sudo apt-get install gcc-4.8 g++-4.8切换gcc版本:sudo update-alternatives原创 2020-07-05 09:26:37 · 3709 阅读 · 1 评论 -
本地导入MNIST手写数据集
在使用tensorflow加载mnist数据集时报错,因为下载数据集的链接被墙了,没法下载数据集。解决方法:step1.手动下载数据集到本地。mnist数据集的格式有两种,一种是gz格式,包含4个文件,一种是npz格式。.gz格式数据集下载:http://yann.lecun.com/exdb/mnist/mnist.npz格式数据集下载:https://pan.baidu.com/s/1kbDiH-nnbgmTRdaZM6c80g 提取码:sg2kstep2.加载本地数据集# 方法1:mni原创 2020-05-17 22:06:09 · 3446 阅读 · 0 评论 -
Tensorflow学习笔记(4)---共享变量:tf.variable_scope() & tf.get_variable() &变量作用域机制
变量作用域机制 tf.get_variable()tf.variable_scope()原创 2020-04-16 16:55:48 · 437 阅读 · 1 评论 -
Tensorflow学习笔记(3)---CPU,GPU的调度
使用字符串string来标识CPU设备或GPU设备:例:'\cpu:0','\gpu:0'在同时拥有CPU和GPU设备时,GPU设备的使用具有优先权记录执行op或tensor的指派设备:设置log_device_placement=True...with tf.Session(config=tf.ConfigProto(log_device_placement=True)) as se...原创 2020-04-15 22:36:23 · 496 阅读 · 0 评论 -
Tensorflow学习笔记(2)---线程和队列
1.先入先出队列:FIFOQueue出队的顺序按入队的顺序,先入队的就先出来 ,从队列前端取出元素入队是进入队列后面,将元素放入队列后端应用场景:主要针对序列样本。使用循环神经网络时,处理语音,文字,视频等序列信息时,希望按顺序执行,这时就使用FIFOQueue队列# 创建“先入先出”队列, 初始化队列,设置队列大小为3, 数据类型为浮点型q = tf.FIFOQueue(5, 'f...原创 2020-04-15 21:54:32 · 187 阅读 · 0 评论 -
Tensorflow安装(1)--ubuntu 下 tensorflow cpu 版本的安装
1. 创建一个虚拟环境conda create --name tensorflow_cpu python=3.5 2. 激活环境source activate tensorflow_cpu3. pip 安装指定版本的tensorflowpip --default-timeout=1000 install -i https://pypi.tuna.tsinghua....原创 2020-04-14 11:04:09 · 470 阅读 · 0 评论