Last active
March 7, 2018 03:23
-
-
Save khanhnamle1994/0020b4231dd4f2a2ae3880e650588a2e to your computer and use it in GitHub Desktop.
Keras Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import keras | |
| import numpy as np | |
| from keras.models import Sequential | |
| from keras.layers.core import Dense, Activation | |
| from keras.optimizers import SGD | |
| # Batch size = 32, Input Dimension = 500, Hidden Dimension = 50 | |
| # Create the model | |
| model = Sequential() | |
| model.add(Dense(input_dim=500, output_dim=50)) | |
| model.add(Activation('relu')) | |
| model.add(Dense(input_dim=50, output_dim=500)) | |
| # Define optimizer object | |
| optimizer = SGD(lr=1e0) | |
| # Compile the model | |
| model.compile(loss='mean_squared_error', optimizer=optimizer) | |
| # Randomize data | |
| x = np.random.randn(32, 500) | |
| y = np.random.randn(32, 500) | |
| # Fit the model | |
| model.fit(x, y, epochs=50, batch_size=64, verbose=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment