原文:tensorflow使用Session模塊時報錯:AttributeError: module 'tensorflow' has no attribute 'Session',已解決

安裝好tensorflow . 之后,當使用Session時,報錯AttributeError: module tensorflow has no attribute Session : 源代碼: import tensorflow as tf import os os.environ CUDA VISIBLE DEVICES a tf.constant b tf.constant with tf ...

2020-03-27 21:17 4 59653 推薦指數:

查看詳情

module 'tensorflow' has no attribute 'Session'的解決辦法

首先出現這個問題的原因是你所用的tensorflow版本不支持session(只有tensorflow版本1支持session)。所以我們只需要在使用session時讓你的版本兼容第一版就行。 session是第一版的所以我們只需要在代碼中加入compat.v1(英文的中文意思就是兼容v1 ...

Mon Feb 28 02:50:00 CST 2022 0 9374
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM