TensorFlow遇到的问题汇总(持续更新中......)

本文详细解析了在使用TensorFlow进行深度学习项目时常见的五种错误,包括softmax_cross_entropy_with_logits函数调用方式的更新、concat函数类型错误、Split操作维度不匹配、废弃的pack函数及feed数据格式问题,并提供了相应的解决策略。
部署运行你感兴趣的模型镜像

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],用返回值。

 

您可能感兴趣的与本文相关的镜像

TensorFlow-v2.15

TensorFlow-v2.15

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值