无法以任何方式投射tensorflow数据类型

时间:2019-01-30 06:22:02

标签: python python-3.x tensorflow

我在Tensorflow中遇到一个错误,它说的是关于数据类型的,但是没有修复程序。

python some_great_model.py
WARNING:tensorflow:From /home/anaconda2/envs/tf_gpu/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Use the retry module or similar alternatives.
Traceback (most recent call last):
  File "/home/anaconda2/envs/tf_gpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
    preferred_dtype=default_dtype)
  File "/home/anaconda2/envs/tf_gpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1040, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/home/anaconda2/envs/tf_gpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 883, in _TensorTensorConversionFunction
    (dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype int64 for Tensor with dtype float32: 'Tensor("sequence_sparse_softmax_cross_entropy/zeros_like:0", shape=(?, ?, 10004), dtype=float32)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "some.py", line 281, in <module>
    main()
  File "some.py", line 99, in main
    sequence_length=lengths)
  File "losses.py", line 223, in sequence_sparse_softmax_cross_entropy
    losses = my_loss(labels, logits)
  File "losses.py", line 46, in focal_loss
    pos_p_sub = array_ops.where(target_tensor > zeros, target_tensor - sigmoid_p, zeros)
  File "/home/anaconda2/envs/tf_gpu/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 2924, in greater
    "Greater", x=x, y=y, name=name)
  File "/home/anaconda2/envs/tf_gpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 546, in _apply_op_helper
    inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Greater' Op has type float32 that does not match type int64 of argument 'x'.

铸造不起作用,使用tf.float32或tf.int64的任何铸造都不起作用。我在这上停留了两天。

如果有任何解决方法,请让我知道。

0 个答案:

没有答案