Created
September 15, 2018 13:56
-
-
Save sdcubber/df8533bd890859223340ded0edc6e835 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
# Sequential API: define a model, add linear stack of layers | |
sequential_network = models.Sequential() | |
sequential_network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28, ), name='input')) | |
sequential_network.add(layers.Dense(256, activation='relu', name='dense_layer')) | |
sequential_network.add(layers.Dense(10, activation='softmax', name='output')) | |
# Functional API: tie layers together in a potentially complex DAG, wrap in a keras Model | |
input_layer = keras.layers.Input((28*28, )) | |
dense_layer = keras.layers.Dense(512, activation='relu')(input_layer) | |
dense_layer = keras.layers.Dense(256, activation='relu')(dense_layer) | |
output_layer = keras.layers.Dense(10, activation='softmax')(dense_layer) | |
functional_network = keras.models.Model(inputs=input_layer, outputs=output_layer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment