from keras.models import Sequential
from keras.layers import *
import numpy as np
from keras import optimizers
#hyperparameters
epochs = 200
epo = np.arange(0, epochs, 1)
n_samples = 40
train_x = np.linspace(0, 20, n_samples)
train_y = -2 * np.linspace(0, 20, n_samples) + 3
x = train_x.reshape(-1, 1) #/ 10**3
y = train_y.reshape(-1, 1) #/ 10**3
model = Sequential()
model.add(Dense(units = 1, input_shape = (1, )))
model.add(Activation('linear'))
model.compile(loss='mean_squared_error',
optimizer=optimizers.SGD(lr=0.001),
metrics=['mse', 'acc'])
history = model.fit(x = x, y = y, batch_size = 1, epochs = epochs)
test_x = np.linspace(0, 20, n_samples)
w, b = model.get_weights()