tensorflow类型错误和值

2024-10-03 09:11:15 发布

您现在位置:Python中文网/ 问答频道 /正文

大家好

我试着在一台新电脑上运行我的程序,但是我收到了所有的错误和警告。从结果来看,似乎所有的问题都来自于张量流。在

我也试过在其他电脑上运行这个程序,没问题。在

第一个问题是,我不明白这些警告是什么意思,在另一台计算机上没有这些警告。在

$ ./run_av.sh
WARNING:tensorflow:From /home/wentao/Sigmedia-AVSR-LRS2/avsr/io_utils.py:208: tf_record_iterator (from tensorflow.python.lib.io.tf_record) is deprecated and will be removed in a future version.
Instructions for updating:
Use eager execution and: 
`tf.data.TFRecorddataset(path)`
WARNING:tensorflow:From /home/wentao/Sigmedia-AVSR-LRS2/avsr/io_utils.py:183: to_int64 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
WARNING:tensorflow:From /home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py:1419: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /home/wentao/Sigmedia-AVSR-LRS2/avsr/video.py:27: conv2d (from tensorflow.python.layers.convolutional) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.conv2d instead.
WARNING:tensorflow:From /home/wentao/Sigmedia-AVSR-LRS2/avsr/video.py:11: batch_normalization (from tensorflow.python.layers.normalization) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.batch_normalization instead.
WARNING:tensorflow:From /home/wentao/Sigmedia-AVSR-LRS2/avsr/cells.py:19: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.
WARNING:tensorflow:From /home/wentao/Sigmedia-AVSR-LRS2/avsr/cells.py:92: MultiRNNCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.
WARNING:tensorflow:From /home/wentao/Sigmedia-AVSR-LRS2/avsr/encoder.py:81: dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `keras.layers.RNN(cell)`, which is equivalent to this API
WARNING:tensorflow:From /home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py:626: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
WARNING:tensorflow:From /home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py:1259: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.
WARNING:tensorflow:From /home/wentao/.local/lib/python3.6/site-packages/tensorflow/contrib/seq2seq/python/ops/helper.py:311: Bernoulli.__init__ (from tensorflow.python.ops.distributions.bernoulli) is deprecated and will be removed after 2019-01-01.
Instructions for updating:
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
WARNING:tensorflow:From /home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/ops/distributions/bernoulli.py:97: Distribution.__init__ (from tensorflow.python.ops.distributions.distribution) is deprecated and will be removed after 2019-01-01.
Instructions for updating:
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
WARNING:tensorflow:From /home/wentao/.local/lib/python3.6/site-packages/tensorflow/contrib/seq2seq/python/ops/helper.py:314: Categorical.__init__ (from tensorflow.python.ops.distributions.categorical) is deprecated and will be removed after 2019-01-01.
Instructions for updating:
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
WARNING:tensorflow:From /home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/ops/distributions/categorical.py:278: multinomial (from tensorflow.python.ops.random_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.random.categorical instead.
/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py:110: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Traceback (most recent call last):
  File "/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 511, in _apply_op_helper
    preferred_dtype=default_dtype)
  File "/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1175, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 977, in _TensorTensorConversionFunction
    (dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype float32 for Tensor with dtype resource: 'Tensor("Decoder/video/Encoder/multi_rnn_cell/cell_0/lstm_cell/kernel/AMSGrad:0", shape=(), dtype=resource)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "experiment_tcd_av.py", line 64, in <module>
    main(sys.argv)
  File "experiment_tcd_av.py", line 47, in main
    num_gpus=1,
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/avsr.py", line 193, in __init__
    self._create_models()
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/avsr.py", line 381, in _create_models
    batch_size=self._hparams.batch_size[0])
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/avsr.py", line 418, in _make_model
    hparams=self._hparams
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/seq2seq.py", line 21, in __init__
    self._make_decoder()
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/seq2seq.py", line 113, in _make_decoder
    hparams=self._hparams
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/decoder_bimodal.py", line 51, in __init__
    self._init_decoder()
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/decoder_bimodal.py", line 116, in _init_decoder
    self._init_optimiser()
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/decoder_bimodal.py", line 514, in _init_optimiser
    zip(gradients, variables), global_step=tf.train.get_global_step())
  File "/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 612, in apply_gradients
    update_ops.append(processor.update_op(self, grad))
  File "/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 171, in update_op
    update_op = optimizer._resource_apply_dense(g, self._v)
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/AMSGrad.py", line 96, in _resource_apply_dense
    m_t = state_ops.assign(m, beta1_t * m + m_scaled_g_values, use_locking=self._use_locking)
  File "/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 812, in binary_op_wrapper
    return func(x, y, name=name)
  File "/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 1078, in _mul_dispatch
    return gen_math_ops.mul(x, y, name=name)
  File "/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 5860, in mul
    "Mul", x=x, y=y, name=name)
  File "/home/wentao/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 547, in _apply_op_helper
    inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Mul' Op has type resource that does not match type float32 of argument 'x'.
Exception ignored in: <bound method AVSR.__del__ of <avsr.avsr.AVSR object at 0x7f3db42332b0>>
Traceback (most recent call last):
  File "/home/wentao/Sigmedia-AVSR-LRS2/avsr/avsr.py", line 198, in __del__
    self._train_session.close()
AttributeError: 'AVSR' object has no attribute '_train_session'

至于ValueError和TypeError,我不知道为什么。在

我刚用过“pip3 install tensorflow”安装tensorflow,但似乎有点不对劲

请帮我或给我一些建议来解决它,谢谢


Tags: andinpyhomeislibtensorflowline