Created
January 22, 2021 00:42
-
-
Save john-adeojo/ada25af2c16a013be5368cbef9f21a6f to your computer and use it in GitHub Desktop.
Deep and Wide NN Build
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
# Build a neural network with deep and wide architecture | |
input_ = keras.layers.Input(shape=(784)) # Input layer | |
hidden1 = keras.layers.Dense(300, activation="relu")(input_) # Create first hidden layer and feed input layer to it | |
hidden2 = keras.layers.Dense(100, activation="relu")(hidden1) # Create 2nd hidden layer and feed output of first hidden layer | |
concat = keras.layers.Concatenate()([input_, hidden2]) # Concatenate output from 2nd hidden layer and input layer | |
output = keras.layers.Dense(10, activation="softmax")(concat) # Feed concatenation of first and second input layer to output layer creating wide and deep network | |
model2 = keras.Model(inputs=[input_], outputs=[output]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment