logo
Loading...

出現module 'tensorflow' has no attribute 'get_default_graph' 錯誤 - Cupoy

執行 homework 的檔案,就遇到以下 Error,請問如何解決?AttributeError ...

ml100-2,ml100-2-d68, build

出現module 'tensorflow' has no attribute 'get_default_graph' 錯誤

2019/11/15 上午 11:19
機器學習共學討論版
Jeng Daw Li
觀看數:30
回答數:2
收藏數:0
ml100-2
ml100-2-d68
build

執行 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:24
    Jeffrey
    贊同數: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

    ```