Created
January 14, 2019 07:10
-
-
Save securetorobert/fef5993cb68afb56fe2bddd7aa948a32 to your computer and use it in GitHub Desktop.
Simple Keras Model with l1_l2 regularization
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 | |
model = keras.models.Sequential([ | |
keras.layers.Dense(4, activation=tf.nn.relu, input_shape=(4,), kernel_regularizer=keras.regularizers.l1_l2(l1=0.1, l2=0.01)), | |
keras.layers.Dense(4, activation=tf.nn.relu, kernel_regularizer=keras.regularizers.l1_l2(l1=0.1, l2=0.01)), | |
keras.layers.Dense(1, activation=tf.nn.sigmoid) | |
]) | |
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment