Last active
June 27, 2020 20:15
-
-
Save ahmetozlu/55bc76afbb0b8287adbfe82ce76ce839 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
# Create model | |
model = Sequential() | |
model.add(Dense(128, activation="relu", input_dim=6)) | |
model.add(Dense(32, activation="relu")) | |
model.add(Dense(8, activation="relu")) | |
# Since the regression is performed, a Dense layer containing a single neuron with a linear activation function. | |
# Typically ReLu-based activation are used but since it is performed regression, it is needed a linear activation. | |
model.add(Dense(1, activation="linear")) | |
# Compile model: The model is initialized with the Adam optimizer and then it is compiled. | |
model.compile(loss='mean_squared_error', optimizer=Adam(lr=1e-3, decay=1e-3 / 200)) | |
# Patient early stopping | |
es = EarlyStopping(monitor='val_loss', mode='min', verbose=1, patience=200) | |
# Fit the model | |
history = model.fit(X1, Y1, validation_data=(X2, Y2), epochs=10000000, batch_size=100, verbose=2, callbacks=[es]) | |
# Calculate predictions | |
PredTestSet = model.predict(X1) | |
PredValSet = model.predict(X2) | |
# Save predictions | |
numpy.savetxt("trainresults.csv", PredTestSet, delimiter=",") | |
numpy.savetxt("valresults.csv", PredValSet, delimiter=",") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment