logo
Loading...

建立keras model出現This model has not yet been built. Build the model first by calling `build()` or calling `fit()` with some data, or specify an `input_shape` argument in the first layer(s) for automatic build 錯誤 - Cupoy

在HW11內的程式碼,如下: classifier = Sequential()classifier...

建立keras model出現This model has not yet been built. Build the model first by calling `build()` or calling `fit()` with some data, or specify an `input_shape` argument in the first layer(s) for automatic build 錯誤

2019/12/10 下午 01:29
電腦視覺深度學習討論版
王政雲
觀看數:489
回答數:2
收藏數:0

在HW11內的程式碼,如下: 

classifier = Sequential()

classifier.add(Convolution2D(filters = (3,3),kernel_size =32))


print(classifier.summary())

# 下列會無法執行,回出現錯誤,想問一下這一行是不適寫錯了,看錯誤法需要先call  build() fit() 才會建立模型。

ValueError: This model has not yet been built. Build the model first by calling `build()` or calling `fit()` with some data, or specify an `input_shape` argument in the first layer(s) for automatic build.

回答列表

  • 2019/12/10 下午 01:40
    周乃森
    贊同數:0
    不贊同數:0
    留言數:0

    第一層需要`input_shape` argument

  • 2019/12/10 下午 09:24
    楊哲寧
    贊同數:0
    不贊同數:0
    留言數:0

    是的,正如周同學的回答,以add的方式搭建NN層,第一層必須先指定輸入影像大小input_shape=(28,28,1)