Created
July 31, 2015 16:22
-
-
Save napsternxg/723a39071659bb763cff to your computer and use it in GitHub Desktop.
Implementing linear regression in keras
This file contains 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
""" | |
Author: Shubhanshu Mishra | |
Posted this on the keras issue tracker at: https://github.com/fchollet/keras/issues/108 | |
Implementing a linear regression using Keras. | |
""" | |
from keras.models import Sequential | |
from keras.layers.core import Dense, Activation | |
model = Sequential() | |
model.add(Dense(2,1,init='uniform', activation='linear')) | |
model.compile(loss='mse', optimizer='rmsprop') | |
model.fit(X_train, y_train, nb_epoch=1000, batch_size=16,verbose=0) | |
model.fit(X_train, y_train, nb_epoch=1, batch_size=16,verbose=1) | |
score = model.evaluate(X_test, y_test, batch_size=16) |
@scottlawsonbc This will work if you reformat the Dense layer to the new format.
Hello, I'm knew to Keras. Can you show me how to write it with the new Dense format? Thanks!
@qks1lver it should be model.add(Dense(1, input_dim=2)) for the new api I think assuming 1 output from two input
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No longer works on the latest version of Keras