關於tensorflow中tf.enable_eager_execution()相關問題

在使用tensorflow過程中,會有以下幾個問題,在未在代碼中添加tf.enable_eager_execution()之前會出現以下問題,在添加之後即可解決

  1. 在運行grads = tape.gradient(loss, variables)這句代碼時會報錯:AttributeError: 'RefVariable' object has no attribute '_id'
  2. 在運行MLP模型時,print("batch %d: loss %f" % (batch_index, loss.numpy()))這一行代碼出現錯誤:'Tensor' object has no attribute 'numpy

 

暫時這些,後面遇到會繼續補充。當然,也歡迎補充-。-

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章