【Python debug】TypeError: Value passed to parameter ' ' has DataType float32 not in list of allowed..

错误信息:

Traceback (most recent call last):
  File "spritegen.py", line 71, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 44, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "spritegen.py", line 51, in main
    cp_directory=FLAGS.checkpoint_dir)
  File "/home/lewis/Documents/Sprite Generator/Sprite-Generator/dcgan.py", line 99, in __init__
    self.build()
  File "/home/lewis/Documents/Sprite Generator/Sprite-Generator/dcgan.py", line 113, in build
    self.G = self.generator(self.z)
  File "/home/lewis/Documents/Sprite Generator/Sprite-Generator/dcgan.py", line 281, in generator
    self.h0 = tf.reshape(self.z,[-1, sample_H16, sample_W16, self.gen_dimension * 8])
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 2630, in reshape
    name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 585, in apply_op
    param_name=input_name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 61, in _SatisfiesTypeConstraint
    ", ".join(dtypes.as_dtype(x).name for x in allowed_list)))
TypeError: Value passed to parameter 'shape' has DataType float32 not in list of allowed values: int32, int64

这个类型的错误信息需要将参数类型进行转换,要注意的是,修改具体调用了包含那个参数的函数就可以了。

我的错误信息返回了很多,修改时需要改的地方为:

self.h0 = tf.reshape(self.z,[-1, sample_H16, sample_W16, self.gen_dimension * 8])

 将其中的参数进行类型转换,改为:

self.h0 = tf.reshape(self.z,[-1, sample_H16, sample_W16, int(self.gen_dimension * 8)])

以上。 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值