Implementing linear regression in keras
""" | |
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) |
This comment has been minimized.
This comment has been minimized.
@scottlawsonbc This will work if you reformat the Dense layer to the new format. |
This comment has been minimized.
This comment has been minimized.
Hello, I'm knew to Keras. Can you show me how to write it with the new Dense format? Thanks! |
This comment has been minimized.
This comment has been minimized.
@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
This comment has been minimized.
No longer works on the latest version of Keras