About the Keras version 2.0 run Demo error problem __ Neural network

Source: Internet
Author: User
Tags keras
about the Keras 2.0 version of the Run demo error problem

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, m), activation= ' Relu '))
f:/  Program Files (x86)/jetbrains/pycharmprojects/untitled1/cnn4.py:30:userwarning:update your ' conv2d ' call 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 argument has been renamed Epochs. So the training times of neural networks need to be defined with everywhere, no longer epochs.

Model.fit (X_train, Y_train, Validation_data= (X_test, Y_test), nb_epoch=69, batch_size=200, verbose=2)
Model.fit (X_train, Y_train, Validation_data= (X_test, Y_test), epochs=69, batch_size=200, verbose=2)

2, convolution* layers are renamed conv*. So the definition of the convolution layer needs to be conv2d instead of convolution2d.

Model.add (convolution2d (5, 5), padding= ' valid ', input_shape= (1, a), activation= ' Relu '))
Model.add (conv2d (5, 5), padding= ' valid ', input_shape= (1, a), activation= ' Relu '))

The appropriate imported packages are:

From keras.layers.convolutional import conv2d

is no longer:

From keras.layers.convolutional import convolution2d

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.