###### #编程环境: Anaconda3 (64-bit)->spyder (python3.5)
fromKeras.modelsImportSequential #引入keras库 fromKeras.layers.coreImportDense, Activationmodel= Sequential ()#Building a modelModel.add (Dense (12,input_dim=2))#Input Layer 2 node, hide layer 12 nodes (The number of nodes can be set by itself)
Model.add (Activation ('Relu'))#Use the Relu function as an activation function to provide significant accuracy
Model.add (Dense (1,input_dim=12))#dense hidden layer 12 node, output layer 1 node
Model.compile (loss='Mean_squared_error', optimizer='Adam')#compiling the Model
Model.fit (X_train, y_train, Nb_epoch = 10000, batch_size = 16)#training model, learning 10,000 times; an optimization algorithm for batch_size deep learning
Model.save_weights (Modelfile)#Saving model Parameters
The above is the main code to estimate the price of a city in grey:
- Keras: Deep Learning Library, Keras-based underlying library uses Theano or tensorflow, so introducing this library requires first installing TensorFlow
- add: support for sequential operations such as: through
Model.add (Dense (12,input_dim=2)) Model.add (Activation (' Relu ')) Add elements of the model in turn
dense layer (fully connected layer): mainly defines the main structure of input, output and hidden layer of the model.
Dense (12,input_dim=2) is a hidden layer of 12 nodes, the input layer is 2 nodes, and the input layer must be the second parameter.
python-Grey forecast Average house price trend Kera Deep Learning Library Introduction