Skip to content

Instantly share code, notes, and snippets.

@jskDr
Created May 22, 2017 04:03
Show Gist options
  • Save jskDr/1754fa429560e6a052081781f0567396 to your computer and use it in GitHub Desktop.
Save jskDr/1754fa429560e6a052081781f0567396 to your computer and use it in GitHub Desktop.
Siimplied Keras for Users
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