Created
May 31, 2020 17:28
-
-
Save rayheberer/493389ffc0d82a05ab6b6ea44a66c505 to your computer and use it in GitHub Desktop.
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 tf.keras.regularizers import l2 | |
def build_nn(input_shape, | |
hidden_units=(20, 20), | |
output_size=1, | |
output_activation=None, | |
hidden_activation=tf.nn.relu, | |
dropout=0.0, | |
regularization=0.0): | |
inputs = tf.keras.Input(shape=input_shape) | |
hidden = inputs | |
for layer_units in hidden_units: | |
hidden = tf.keras.layers.Dense(layer_units, activation=hidden_activation, kernel_regularizer=l2(regularization))(hidden) | |
hidden = tf.keras.lyaers.Dropout(dropout)(hidden) | |
outputs = tf.keras.layers.Dense(output_size, activation=output_activation, kernel_regularizer=l2(regularization))(hidden) | |
model = tf.keras.Model(inputs=inputs, outputs=outputs) | |
return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment