-
-
Save Charlie13/8d49ce76d1523efdc330f74e591187a8 to your computer and use it in GitHub Desktop.
Siimplied Keras for Users
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
| from keras import layers, models | |
| Nin = 784 | |
| Nh = 100 | |
| number_of_class = 10 | |
| Nout = number_of_class | |
| class ANN(models.Model): | |
| def __init__(self, Nin, Nh, Nout): | |
| # Prepare network layers and activate functions | |
| hidden = layers.Dense(Nh) | |
| output = layers.Dense(Nout) | |
| relu = layers.Activation('relu') | |
| softmax = layers.Activation('softmax') | |
| # Connect network elements | |
| x = layers.Input(shape=(Nin,)) | |
| h = relu(hidden(x)) | |
| y = softmax(output(h)) | |
| super().__init__(x, y) | |
| self.compile(loss='categorical_crossentropy', | |
| optimizer='adam', | |
| metrics=['accuracy']) | |
| model = ANN(Nin, Nh, Nout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment