![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Tensorflow学习
黄鑫huangxin
深度学习,多媒体分析与理解
知乎专栏:https://www.zhihu.com/people/mu-xi-jin-39/columns
Github: https://github.com/BonnieHuangxin
展开
-
Tensorflow 中tf.shape(a)和a.get_shape()的区别
一、tf.shape(a) 和 a.get_shape()比较相同点:都可以得到tensor a 的尺寸 不同点:tf.shape(a)中a数据的类型可以是tensor,list,array,而a.get_shape()中的a的数据类型必须是tensor,且返回的是一个tuple.可以通过a.get_shape().as_list()得到一个list二、tf.shape(a)的使用 ...原创 2018-09-15 22:02:48 · 648 阅读 · 0 评论 -
tf.reshape()的Tensorflow 1.0 版本问题报错
tf.reverse tf.reverse之前会用一维 bool 张量控制要颠倒哪些维度。现在我们使用轴索引张量。 例如,tf.reverse(a, [True, False, True]) 现在必须是 tf.reverse(a, [0, 2]) tf.reverse_sequence 关键字参数 batch_dim 应重命名为 batch_...原创 2018-11-04 19:24:27 · 286 阅读 · 0 评论 -
Tensorflow 低版本代码自动升级为1.0版本
TensorFlow 1.0 中的 API 有所变化,参数位置发现变化,造成在 TensorFlow 0.n 上运行的 TensorFlow 程序无法在 TensorFlow 1.0 上运行。自动将代码移植到 1.0,有一个转换工具。GitHub工具包地址:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/too...原创 2018-11-06 17:17:36 · 642 阅读 · 0 评论 -
TensorFlow之入门基础知识
一、Session会话控制定义两个常量矩阵a,b(tf.constant)a = tf.constant([[1.0,2.0]],name = 'a')b = tf.constant([[2.0], [3.0]],name = 'a')product = tf.matmul(a,b)要输出相加得到的结果,不能直接输出result,需要先生成一个会...原创 2018-11-03 10:41:50 · 361 阅读 · 0 评论 -
TensorFlow之MNIST 分类以及Dropout的使用
一、简单的一层神经网络import tensorflow as tf#下载MNIST数据集(28*28,输入维度为784)from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets('MNIST_data', one_hot=True)#构建简单的一层神...原创 2018-11-03 10:36:39 · 733 阅读 · 0 评论 -
TensorFlow之CNN卷积神经网络的实现
下载MNIST数据集(28*28,输入维度为784)import tensorflow as tf#下载MNIST数据集(28*28,输入维度为784)from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets('MNIST_data', one_hot=Tr...原创 2018-11-03 10:28:30 · 399 阅读 · 2 评论 -
Tensorflow之模型参数的Saver保存读取
一、Saver保存import tensorflow as tfimport numpy as np#定义W和bW = tf.Variable([[1,2,3],[3,5,6]],dtype = tf.float32,name = 'weight')b = tf.Variable([1,2,3],dtype = tf.float32,name = 'biases')#注:初始化变...原创 2018-11-03 10:23:32 · 443 阅读 · 0 评论 -
AttributeError: module 'tensorflow.python.ops.rnn' has no attribute 'rnn'
TensorFlow原版本报错:AttributeError: module 'tensorflow.python.ops.rnn' has no attribute 'rnn'from tensorflow.python.ops import rnn, rnn_cell lstm_cell = rnn_cell.BasicLSTMCell(rnn_size,state_is_tuple=...原创 2018-10-16 20:35:14 · 8128 阅读 · 1 评论 -
Jupyter notebook 服务器远程配置(Ubuntu16.04)
Jupyter notebook 简单易用,远程连接之后可以在线写代码,管理文件,运行终端。网上的远程配置教程已经有很多,但是都相似且不够全面,在我配置的时候仍然出现了一些问题,这里做一个记录。一、步骤1编辑配置文件, Linux在:/home/.jupyter/jupyter_notebook_config.py若没有,则在命令行重新生成配置文件:jupyter noteb...原创 2018-10-18 19:08:50 · 328 阅读 · 0 评论 -
Bi-LSTM的理解以及 Tensorflow实现
Bidirectional LSTM,由两个LSTMs上下叠加在 一起组成。输出由这两个LSTMs的隐藏层的状态决定。def bilstm(self,x): # 输入的数据格式转换 # x.shape [batch_size, time_steps, input_size] x=tf.transpose(x,[1,0,2]...原创 2018-10-15 14:59:36 · 16702 阅读 · 1 评论 -
tf.tile()用法及实例
tf.tile( input, #输入 multiples, #某一维度上复制的次数 name=None )实例import tensorflow as tfa = tf.tile([1,2,3],[2])b = tf.tile([[1,2], [3,4], [5,6]],[2,3...原创 2018-09-19 22:08:32 · 8432 阅读 · 0 评论 -
报错 initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed
WARNING:tensorflow:From /home/hndx532/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/tf_should_use.py:118: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated ...原创 2018-09-19 14:35:33 · 8311 阅读 · 3 评论 -
Input ‘split_dim’ of ‘Split’ Op has type float32 that does not match expected type of int32 报错
#原来是这样的:This is because in Tensorflow versions < 0.12.0 the split function takes the arguments as:x = tf.split(0, n_steps, x) # tf.split(axis, num_or_size_splits, value)#修改成这样的:The tutorial y...原创 2018-09-19 13:39:50 · 2495 阅读 · 0 评论 -
转:汇总Tensorflow1.0运行之前版本代码报错问题
注:在Tensorflow1.0运行之前版本,以及py2与py3文件编码遇到很多问题。这里转发了网上的汇总报错解决方法。1.TypeError: Expected int32, got list containing Tensors of type ‘_Message’ instead.tensorflow 函数tf.cocat([fw,bw],2)出错:Expected int3...转载 2018-09-19 12:12:20 · 404 阅读 · 0 评论 -
交叉熵损失函数及Tensorflow实现
一、交叉熵损失原理一般情况下,在分类任务中,神经网络最后一个输出层的节点个数与分类任务的标签数相等。假设最后的节点数为N,那么对于每一个样例,神经网络可以得到一个N维的数组作为输出结果,数组中每一个维度会对应一个类别。在最理想的情况下,如果一个样本属于k,那么这个类别所对应的第k个输出节点的输出值应该为1,而其他节点的输出都为0,即[0,0,1,0,….0,0],这个数组也就是样本的Lab...原创 2018-09-17 13:15:01 · 6097 阅读 · 0 评论 -
ubuntu16.04更改CUDNN 6.0 版本
在 ubuntu16.04 上安装tensorflow-gpu发现没有对应版本。查看之后,我的电脑是cuda 8.0,cudnn 7版本所以需要更换cudnn版本为6.0,才可以安装tensorflow-gpu一、下载linux版的CUDNN 6.0官网下载:https://developer.nvidia.com/cuDNN,需要邮箱注册。二、安装1)解压到下载的目录下:...原创 2018-11-08 18:17:18 · 478 阅读 · 0 评论