TensorFlow has no attribute “with_dependencies”

前端 未结 3 1167
攒了一身酷
攒了一身酷 2021-01-13 11:35

I want to use the tf.with_dependencies function to save the state of my RNNs. For some reason I get the following error.



        
相关标签:
3条回答
  • 2021-01-13 11:51

    Or try: from tensorflow.python.ops.control_flow_ops import with_dependencies

    0 讨论(0)
  • 2021-01-13 11:54

    There is no such function in the TensorFlow API. Instead you can use with tf.control_dependencies(): and tf.identity() to achieve the intended effect:

    with tf.control_dependencies([expected_output]):
      result = tf.identity(input_tensor)
    
    0 讨论(0)
  • 2021-01-13 12:06

    tf.with_dependencies was deprecated somewhere in the end of 2015. Nonetheless it is still defined in the tf code, it is no longer exported (no @tf_export in front of the function) and therefore is not available.

    Use

    with tf.control_dependencies([expected_output]):
      result = tf.identity(input_tensor)
    

    as suggested by mrry, as it does absolutely the same thing.

    0 讨论(0)
提交回复
热议问题