【发布时间】:2018-07-25 07:09:12
【问题描述】:
我正在 TensorFlow 中实现 Wasserstein DCGAN。运行此行时发生错误:train_image = sess.run(image_batch)。处理这个异常又抛出一个异常
Fetch argument array([[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]],
[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]],
[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]],
...,
[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]],
[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]],
[[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]]], dtype=uint8) has invalid type <class 'numpy.ndarray'>, must be a string or Tensor. (Can not convert a ndarray into a Tensor or Operation.)
我正在使用通过此命令获取的 MNIST 数据集 -->
from keras.datasets import mnist
(X_train, Y_train), (X_test, Y_test) = mnist.load_data()
完整的源代码:https://github.com/tanmay-bhatnagar/W-DCGAN 将 TensorFlow 1.4.1 和 python 3.6 与所有其他库的最新版本一起使用。 请询问任何其他所需的详细信息。
【问题讨论】:
-
rain_image = sess.run(image_batch)行的目的是什么?您不能将 numpy 数组传递到那里。 -
你的
process_data函数返回numpy数组但是pokeGan的返回tensorflow操作(可以传入sess.run()) -
这可能有效。在返回之前将
tf.reshape(image_batch, [-1,64,64,1])添加到process_data。 -
或者你也可以
np.reshape()直接喂到real_image。 -
您是否从代码中删除了
train_image = sess.run(image_batch)?你应该保留它。
标签: python-3.x tensorflow deep-learning keras conv-neural-network