TensorFlow遇到的问题汇总(持续更新中......)
2017-05-17 11:20 猎手家园 阅读(52907) 评论(0) 编辑 收藏 举报1、调用tf.softmax_cross_entropy_with_logits函数出错。
#原因是这个函数,不能按以前的方式进行调用了,只能使用命名参数的方式来调用。 #原来是这样的: tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(y, y_)) #修改成这样的: tf.reduce_sum(tf.nn.softmax_cross_entropy_with_logits(logits=y, labels=y_))
2、Tensorflow 函数tf.cocat([fw,bw],2)出错:TypeError: Expected int32, got list containing Tensors of type ‘_Message’ instead.
Expected int32, got list containing Tensors of type ‘_Message’ inst
原因是11版本的函数形式为:tf.concat(2,[fw,bw]),即应把串联的维度与串联值位置调换即可.
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 you are working from was written for versions > 0.12.0, which has been changed to be consistent with Numpy’s split syntax: x = tf.split(x, n_steps, 0) # tf.split(value, num_or_size_splits, axis)
4、‘module’ object has no attribute ‘pack’
因为TF后面的版本修改了这个函数的名称,把 tf.pack 改为 tf.stack。
5、The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, or numpy ndarrays
数据集是feed输入的,feed的数据格式是有要求的。
解决:img,label = sess.run[img,label], 用返回值。
6、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)
7、Variable basic/rnn/basic_lstm_cell/weights does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?
with tf.variable_scope(scope_name, reuse=None) as scope: scope.reuse_variables() w = tf.get_variable("weight", shape, initializer = random_normal_initializer(0., 0.01))) b = tf.get_variable("biase", shape[-1], initializer = tf.constant_initializer(0.0)) #或: with tf.variable_scope(scope_name, reuse=True): w = tf.get_variable("weight") b = tf.get_variable("biase")

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
2016-05-17 极限存储之拉链表
2016-05-17 CentOS6.5安装sqoop2
2016-05-17 CentOS6.5 安装Kafka集群
2016-05-17 CentOS6.5 安装Storm集群
2016-05-17 CentOS6.5 安装Spark集群
2016-05-17 Linux下修改MySQL数据库字符编码为UTF-8解决中文乱码