Last active
March 16, 2018 13:50
-
-
Save mikaelsouza/2de822fb8db23938a5dd8b9d11a33cbf to your computer and use it in GitHub Desktop.
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 | |
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