Created
September 17, 2016 18:47
-
-
Save macromaniac/630df68eb42d881755a3e30343252f74 to your computer and use it in GitHub Desktop.
simple linear regression example using 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
import numpy as np | |
from keras.layers import Dense, Input | |
from keras.models import Model | |
x = Input((1,)) | |
y = Dense(1, activation ='linear')(x) | |
m = Model(x,y) | |
m.compile(loss = 'mse', optimizer='sgd') | |
_x = np.linspace(1,2, num = 1e3) | |
m.fit(_x, 2*_x + 1, batch_size=1) | |
print m.get_weights() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have been desperately trying to create an ANN and match it with Regression coefficients. This work saved my day. Thanks.