TypeError:预期的uint8,取而代之的是类型为“ float”的0.0

时间:2019-02-22 18:33:47

标签: python python-2.7 tensorflow q

这些是我认为在使用TF构建U-net模型时引起问题的关键信息。

我不知道tensorlayer.layers定义的Conv2d层怎么会出错。

我很确定占位符的dtype是uint8 这是我的声明方式:

X_placeholder = tf.placeholder(uint8 , (num_of_input_image, 284, 284, 3))

然后我将X-placeholer用作自定义模型的输入。

Con2d用于我的自定义模型中,但是似乎不起作用。 如果需要更多信息,请告诉我。

(我确实看到了类似的问题,例如this

Traceback (most recent call last):

File "model.py", line 104, in <module>
    main()  
File "model.py", line 32, in main    
    net = u_net(X_placeholder ,is_train = True , n_out=1)  
File "model.py", line 68, in u_net    
    conv1 = Conv2d(inputs, 64, (3, 3), act=tf.nn.relu, name='conv1_1')
...
...
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/init_ops.py", line 336, in __call__
    shape, self.mean, self.stddev, dtype, seed=self.seed)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/random_ops.py", line 170, in truncated_normal
    mean_tensor = ops.convert_to_tensor(mean, dtype=dtype, name="mean")
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1011, in convert_to_tensor
    as_ref=False)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1107, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 217, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 196, in constant
    value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 436, in make_tensor_proto
    _AssertCompatible(values, dtype)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 347, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected uint8, got 0.0 of type 'float' instead.

0 个答案:

没有答案