【tensorflow】报错汇总

1、TypeError: The value of a feed cannot be a tf.Tensor object

TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, numpy ndarrays, or TensorHandles. For reference, the tensor object was Tensor(“Reshape_6:0”, shape=(50, 28, 28, 1), dtype=float32) which was passed to the feed with key Tensor(“Placeholder_3:0”, shape=(?, 28, 28, 1), dtype=float32).

问题分析及解决方法:
产生该问题的原因是在tf.reshape()后,该数据是一个tf.Tensor对象,而tf.placeholder()方法feed的数据不能为tf.Tensor对象。使用np.reshape()就可以了。

2、Failed to load the native TensorFlow runtime.

安装完TensorFlow GPU版本时,报错Failed to load the native TensorFlow runtime.
解决办法,使用conda install tensorflow=1.12.0安装TensorFlow。

3、Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.

解决方法:
首先确定cuda和cudnn版本是否匹配,若匹配,则在代码中进行如下设置:

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
#session = tf.InteractiveSession(config=config)     						# 纯tf版
tf.keras.backend.set_session(tf.Session(config=config))			# tf.keras版

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值