tensorflow1.5 python2.7版本下执行,错误的解决。
一、前言:
1整个过程使用debuger方式执行,设置断点 。
2重点执行时候用下面两种方法 1表示的按钮执行一步一步调试,能看到中间结果在每一步的值,2按钮直接跳出到出错前的位置。
挨着debugger按钮的窗口是console,可以显示中间执行过程,最后停止后,看debugger窗口:'./data/faces_/7c34548743ce2835920552cd8cc7d4c8-0.jpg'提示错误的图像路径。
3 另外:执行时候记得设置参数,并加上 --is_crop True否则提示 维数不匹配,因为原图片是108*108的 faces数据。
在run菜单 --EDIT CONFIGURATION...菜单打开的窗口中配置
二、具体错误:
1、TypeError: Value passed to parameter 'shape' has DataType float32 not in list of allowed values: int32, int64
model.py中的350行后面的几行代码 加int强制转换:
def generator(self, z, y=None):
with tf.variable_scope("generator") as scope:
if not self.y_dim:
s_h, s_w = self.output_height, self.output_width
s_h2, s_w2 = int(conv_out_size_same(s_h, 2)), int(conv_out_size_same(s_w, 2))
s_h4, s_w4 = int(conv_out_size_same(s_h2, 2)), int(conv_out_size_same(s_w2, 2))
s_h8, s_w8 = int(conv_out_size_same(s_h4, 2)), int(conv_out_size_same(s_w4, 2))
s_h16, s_w16 = int(conv_out_size_same(s_h8, 2)), int(conv_out_size_same(s_w8, 2))
model.py中的411行后面的几行代码 加int强制转换:
def sampler(self, z, y=None):
with tf.variable_scope("generator") as scope:
scope.reuse_variables()
if not self.y_dim:
411 s_h, s_w = self.output_height, self.output_width
s_h2, s_w2 = int(conv_out_size_same(s_h, 2)), int(conv_out_size_same(s_w, 2))
s_h4, s_w4 = int(conv_out_size_same(s_h2, 2)),int(conv_out_size_same(s_w2, 2))
s_h8, s_w8 = int(conv_out_size_same(s_h4, 2)), int(conv_out_size_same(s_w4, 2))
s_h16, s_w16 = int(conv_out_size_same(s_h8, 2)),int(conv_out_size_same(s_w8, 2))
2 后来继续执行 到:
Epoch: [ 0] [ 734/ 800] time: 291.7959, d_loss: 1.45465708, g_loss: 0.52461040 即 734次后,
Traceback (most recent call last):
File "/home/gis/PycharmProjects/guo/DCGAN-tensorflow-masterlm/main.py", line 97, in <module>
tf.app.run()
File "/home/gis/anaconda3/envs/Pytguo27/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 124, in run
_sys.exit(main(argv))
File "/home/gis/PycharmProjects/guo/DCGAN-tensorflow-masterlm/main.py", line 80, in main
dcgan.train(FLAGS)
File "/home/gis/PycharmProjects/guo/DCGAN-tensorflow-masterlm/model.py", line 211, in train
grayscale=self.grayscale) for batch_file in batch_files]
File "/home/gis/PycharmProjects/guo/DCGAN-tensorflow-masterlm/utils.py", line 28, in get_image
image = imread(image_path, grayscale)
File "/home/gis/PycharmProjects/guo/DCGAN-tensorflow-masterlm/utils.py", line 39, in imread
return scipy.misc.imread(path).astype(np.float)
TypeError: float() argument must be a string or a number
Process finished with exit code 1
提示:return scipy.misc.imread(path).astype(np.float)
TypeError: float() argument must be a string or a number
后来查到问题:
(
挨着debugger按钮的窗口是console,可以显示中间执行过程,最后停止后,看debugger窗口:'./data/faces_/7c34548743ce2835920552cd8cc7d4c8-0.jpg'提示错误的图像路径。找到图像发现,图像不完整,导致执行失败。
)
'./data/faces_/7c34548743ce2835920552cd8cc7d4c8-0.jpg''文件出错了,重新替换后,再执行
终于搞定,费了九牛2虎之力。
总算有点收获。