Skip to content

Instantly share code, notes, and snippets.

@mikaelsouza
Last active March 16, 2018 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaelsouza/2de822fb8db23938a5dd8b9d11a33cbf to your computer and use it in GitHub Desktop.
Save mikaelsouza/2de822fb8db23938a5dd8b9d11a33cbf to your computer and use it in GitHub Desktop.
import numpy as np
import sklearn.datasets as datasets
from keras import layers, models, utils
def main():
# Loading dataset
boston_dataset = datasets.load_boston()
# Defining inputs and outputs of the neural network
X = np.array(boston_dataset['data'])
y = np.array(boston_dataset['target'])
# Defining model with 2 layers
# One containing 100 neurons and a output layer
model = models.Sequential()
model.add(layers.Dense(100, input_shape=(13, )))
model.add(layers.Dense(1))
# Defining the model parameters
model.compile(
optimizer='adam',
loss='mean_squared_error',
metrics=['accuracy', 'mae'])
# Training the model
model.fit(X, y, epochs=1000, validation_split=0.1, verbose=2)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment