Last active
May 31, 2018 00:10
-
-
Save z-a-f/1a91fee57380940c73f57452214cbbbe 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
import keras | |
def preprocess_images(images, normalization=255): | |
"""Normalizes the inputs""" | |
dims = images.shape | |
return images.reshape((dims[0], dims[1]*dims[2])).astype('float32') / normalization | |
def preprocess_labels(labels): | |
"""Preprocesses the labels into categorical""" | |
return keras.utils.to_categorical(labels) | |
def get_model(N=512): | |
"""Returns a simple FC model with N nodes in the first hidden layer""" | |
model = keras.models.Sequential() | |
model.add(keras.layers.Dense(N, activation='relu', input_shape=(28*28,))) | |
model.add(keras.layers.Dense(10, activation='tanh')) | |
model.compile(optimizer='rmsprop', loss='mse', metrics=['accuracy']) | |
return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment