所以我试图在Keras中使用小数最大池和CIFAR-10上的Lambda包装器,但每当我尝试训练模型时,运行时就会死掉。关于发生了什么的任何线索?我正在使用带有tensorflow后端的Keras v2.0。
def frac_max_pool(x):
return tf.nn.fractional_max_pool(x,[1.0,1/sqrt(2),1/sqrt(2),1.0])[0]
model = Sequential()
model.add(Conv2D(32,(3,3),padding='same',input_shape=x_train.shape[1:]))
model.add(Activation('relu'))
model.add(Conv2D(32,(3,3)))
model.add(Activation('relu'))
model.add(Lambda(frac_max_pool))
model.add(Dropout(0.25))
model.add(Conv2D(64,(3,3),padding='same',input_shape=x_train.shape[1:]))
model.add(Activation('relu'))
model.add(Conv2D(64,(3,3)))
model.add(Activation('relu'))
model.add(Lambda(frac_max_pool))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(10))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy',optimizer=opt,metrics=
['accuracy'])
model.fit(x_train,y_train,batch_size=32,epochs=100,validation_data=
(x_test,y_test))