Last active
July 17, 2020 20:48
-
-
Save KenoLeon/a5ab55414dac01d63f4e2079296f1730 to your computer and use it in GitHub Desktop.
Build keras model
This file contains hidden or 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 tensorflow as tf | |
| from tensorflow import keras | |
| from tensorflow.keras import layers | |
| def build_model(learning_rate, layer_size): | |
| """Build Keras model""" | |
| model = keras.Sequential([ | |
| layers.Dense(layer_size, activation='relu', | |
| input_shape=[len(feature_names)]), | |
| layers.Dense(layer_size, activation='relu', kernel_regularizer='l2'), | |
| layers.Dense(1, activation='sigmoid') | |
| ]) | |
| optimizer = tf.keras.optimizers.Adam(learning_rate=learning_rate) | |
| model.compile(loss='mse', optimizer=optimizer, metrics=['mae', 'mse']) | |
| return model | |
| # Later called by: | |
| regressor_model = build_model(lr, layer_Size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment