Skip to content

Instantly share code, notes, and snippets.

@Pawandeep-prog
Created May 12, 2020 02:39
Show Gist options
  • Save Pawandeep-prog/e45c90b62b19c22e8bf4971311f3b3ca to your computer and use it in GitHub Desktop.
Save Pawandeep-prog/e45c90b62b19c22e8bf4971311f3b3ca to your computer and use it in GitHub Desktop.
import random
import numpy as np
X =[]
y =[]
for i in range(1000):
X.append([random.randint(1, 1000), random.randint(1, 1000)])
y.append(sum(X[i]))
X = np.array(X)
y = np.array(y).reshape(-1,1)
'''
from sklearn.preprocessing import MinMaxScaler
sclr = MinMaxScaler()
X = sclr.fit_transform(X)
sclr2 = MinMaxScaler()
y = sclr2.fit_transform(y)
'''
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
model.add(Dense(output_dim=6, activation='relu', input_dim=2))
model.add(Dense(output_dim=12, activation='relu'))
model.add(Dense(output_dim=12, activation='relu'))
model.add(Dense(output_dim=6, activation='relu'))
model.add(Dense(output_dim=1, activation='linear'))
model.compile('adam', 'mean_squared_error')
model.fit(X, y, epochs=200)
pred = np.array([[145,25]])
#pred = sclr.transform(pred)
predd = model.predict(pred)
#predd = sclr2.inverse_transform(predd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment