如何解决Keras中 "模型尚未建立 "的错误? | 您所在的位置:网站首页 › keras中的dropout › 如何解决Keras中 "模型尚未建立 "的错误? |
I got this error while working with CNN: This model has not yet been built. Build the model first by calling `build()` or by calling the model on a batch of data.My code is below : from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense,Dropout from tensorflow.keras.layers import Conv2D from tensorflow.keras.layers import Flatten from tensorflow.keras.layers import MaxPooling2D from tensorflow.keras.callbacks import TensorBoard model=Sequential() model.add(Conv2D(32,5,input_shape=(1,28,28),activation='relu',data_format='channels_last')) model.add(MaxPooling2D(pool_size=(2,2),strides=2)) model.add(Flatten()) model.add(Conv2D(64,5,input_shape=(1,28,28),activation='relu',data_format='channels_last')) model.add(MaxPooling2D(pool_size=2,strides=2)) model.add(Flatten()) model.add(Dense(units=32,activation='relu')) model.add(Dropout(0.4)) model.add(Dense(units=1,activation='softmax')) model.summary() |
CopyRight 2018-2019 实验室设备网 版权所有 |