我试图在Keras中构建一个顺序模型,但是当我编译模型时,我得到了这个错误,我该如何修复它
# Step 3: Model Creation
model = Sequential()
model.add(Conv2D(32, (3,3), Input_shape(32, 32, 3), padding = "same", activation = 'relu',
kernel_constraint = maxnorm(3)))
model.add(Dropout(0.2))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Flatten())
model.add(Dense(512, activation = 'relu',kernel_constraint=maxnorm(3)))
model.add(Dropout(0.5))
model.add(Dense(num_classes,activation='relu'))
#Configure the optimizer
sgd = SGD(lr = 0.01, momentum =0.9, decay = (0.01/25),nesterov = False)
#compile the model
model.compile(loss = 'categorical_crossentropy',optimizer = sgd, metrics = ['accuracy'])
这就是我得到的错误:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-32-c2c434db6c57> in <module>()
1 # Step 3: Model Creation
2 model = Sequential()
----> 3 model.add(Conv2D(32, (3,3), Input_shape(32, 32, 3), padding = "same", activation = 'relu',
4 kernel_constraint = maxnorm(3)))
5 model.add(Dropout(0.2))
NameError: name 'Input_shape' is not defined
您在model.add()的args中的第3行缺少=符号:
Input_shape = (32, 32, 3)
相关问题 更多 >
编程相关推荐