文章目录
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版