Keras version 2.0 running demo error
Because it is the neural network small white, when running the demo does not understand Keras version problem, appeared a warning:
C:\ProgramData\Anaconda2\python.exe "F:/program Files (x86)/jetbrains/pycharmprojects/untitled1/cnn4.py"
Using Theano backend.
F:/program Files (x86)/jetbrains/pycharmprojects/untitled1/cnn4.py:27:userwarning:update your ' Conv2D ' to the Keras 2 API: ' Conv2d (5, 5), padding= "valid", activation= "Relu", input_shape= (1, 28, 28 ...) `
Model.add (convolution2d, 5, 5, border_mode= ' valid ', input_shape= (1, 28,28), activation= ' Relu '))
F:/program Files (x86)/jetbrains/pycharmprojects/untitled1/cnn4.py:30:userwarning:update your ' Conv2D ' to the Keras 2 API: ' Conv2d (3, 3), activation= "Relu") '
Model.add (convolution2d, 3, 3, activation= ' Relu '))
C:\programdata\anaconda2\lib\site-packages\keras\models.py:826:userwarning:the ' nb_epoch ' argument in ' fit ' has been Renamed ' Epochs '.
Warnings.warn (' The ' nb_epoch ' argument in ' fit ')
These warnings are due to an issue with the Keras version update, which is a link to the keras2.0 update document:
Https://github.com/fchollet/keras/wiki/Keras-2.0-release-notes
And then again, the way I came up with the warning solution:
1. The Nb_epoch argumenthas been renamed epochs everywhere. So the training times of neural networks need to be defined with epochs, no longer nb_epoch.
Previous wording:
Model.fit (X_train, Y_train,validation_data= (X_test, Y_test), nb_epoch=69, batch_size=200, verbose=2)
Correct wording:
Model.fit (X_train, Y_train,validation_data= (X_test, Y_test), epochs=69, batch_size=200, verbose=2)
2, convolution* Layersare renamed conv*. So the definition of the convolution layer needs to be conv2d instead of convolution2d.
Correct writing: note (5, 5) is enclosed in parentheses, not previously enclosed
From keras.layers.convolutional import conv2d
Model.add (conv2d (5, 5), padding= ' valid ', input_shape= (1, a), activation= ' Relu '))
Previous Error writing:
From keras.layers.convolutional import convolution2d
Model.add (convolution2d (5, 5), padding= ' valid ', input_shape= (1, a), activation= ' Relu '))
If you run the demo again, the warnings are all free.
Therefore, as a beginner or need to pay attention to the keras2.0 version of some of the differences in the wording. I currently only encounter such two problems, if there are other questions about the keras2.0 version, please refer to the author above the link, self-confidence to check.
Reference website:
1, Https://github.com/fchollet/keras/wiki/Keras-2.0-release-notes 2017.4.5