出現module 'tensorflow' has no attribute 'get_default_graph' 錯誤
執行 homework 的檔案,就遇到以下 Error,請問如何解決?
AttributeError Traceback (most recent call last)
<ipython-input-9-ba070084bc2c> in <module>
1 # build our CNN model, 多加幾層
----> 2 model = Sequential()
3 model.add(Conv2D(64, (3, 3), padding='same',
4 input_shape=x_train.shape[1:]))
5 model.add(Flatten())
.................................................
AttributeError: module 'tensorflow' has no attribute 'get_default_graph'
Thanks,
Roger
回答列表
-
2019/11/16 上午 04:24Jeffrey贊同數:0不贊同數:0留言數:0
Hi, 同學,
請問一下, 你的 tensorflow 版本是? tensorflow 2.0 不支持這個API.
可以嘗試下:
import tensorflow as tf
from tensorflow.python.framework import ops
ops.reset_default_graph()
-
2019/11/19 下午 10:02張維元 (WeiYuan)贊同數:0不贊同數:0留言數:0
補充問一下 Jeffery 助教,為什麼你說「 tensorflow 2.0 不支持這個API」,但你這樣寫卻是可以動的?是因為這一段嗎?
```
from tensorflow.python.framework import ops
```