建立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)