深度学习中tensorflow框架的学习

五小郎的学习笔记 2019-06-21

1.如何查看tensorflow版本与存储位置

import tensorflow as tf
print(tf.__version__)
print(tf.__path_)

注:__看着是一个下划线,实际上是两个下划线
本人用的是0.12.0-rc0版本
2.报错module 'tensorflow.python.ops.nn' has no attribute 'rnn_cell'

#原因是1.0版本改了不少地方
#原来是这样的:
from tensorflow.python.ops import rnn, rnn_cell 
lstm_cell = rnn_cell.BasicLSTMCell(rnn_size,state_is_tuple=True) 
outputs, states = rnn.rnn(lstm_cell, x, dtype=tf.float32)

#修改成这样的:
from tensorflow.contrib import rnn 
lstm_cell = rnn.BasicLSTMCell(rnn_size) 
outputs, states = rnn.static_rnn(lstm_cell, x, dtype=tf.float32)

小结:注意版本区别
关于tensorflow报错及纠错方面可以参照链接http://www.cnblogs.com/huntto...

相关推荐