使用Keras时用到了卷积层Convolution2D( )以及Model.fit( ):
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x)
Model.fit(x_train, x_train, nb_epoch=10, batch_size=256, shuffle=True, validation_data=(x_test, x_test))
遇到了如下错误:
UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(1, (3, 3), padding="same", activation="sigmoid")`
decoded = Convolution2D(1, 3, 3, activation='sigmoid', border_mode='same')(x)
......
在查看了github上的Keras 2.0发行说明后,发现这是从Keras 1到Keras 2发生的变化.
此处涉及到的有:
Convolution* 层被重新命名 Conv* ;
border_mode - > padding ;
nb_epoch - > epochs;
kernel_size可以设置为一个整数,例如Conv2D(10, 3)相当于Conv2D(10, (3, 3));
因此,
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x)
Model.fit(x_train, x_train, nb_epoch=10, batch_size=256, shuffle=True, validation_data=(x_test, x_test))
改为:
x = Conv2D(8, 3, activation='relu', padding='same')(x)
Model.fit(x_train, x_train, epochs=10, batch_size=256, shuffle=True, validation_data=(x_test, x_test))
其他更多变化参见:Keras 2.0发行说明