Last active
February 28, 2020 13:48
-
-
Save a-agmon/7ccfeaf598a13f5ba8097dcf51c3dcbe to your computer and use it in GitHub Desktop.
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.models import Model, load_model | |
from keras.layers import Input, Dense, Dropout | |
from keras.callbacks import ModelCheckpoint, TensorBoard | |
from keras import regularizers | |
input_dim = X_train.shape[1] # the # features | |
encoding_dim = 8 # first layer | |
hidden_dim = int(encoding_dim / 2) #hideen layer | |
nb_epoch = 30 | |
batch_size = 128 | |
learning_rate = 0.1 | |
input_layer = Input(shape=(input_dim, )) | |
encoder = Dense(encoding_dim, activation="tanh", activity_regularizer=regularizers.l1(10e-5))(input_layer) | |
encoder = Dense(hidden_dim, activation="relu")(encoder) | |
decoder = Dense(encoding_dim, activation='relu')(encoder) | |
decoder = Dense(input_dim, activation='tanh')(decoder) | |
autoencoder = Model(inputs=input_layer, outputs=decoder) | |
# ----- some data omitted --------- # | |
history = autoencoder.fit(X_train, X_train, | |
epochs=nb_epoch, | |
batch_size=batch_size, | |
shuffle=True, | |
validation_data=(X_test, X_test), | |
verbose=1, | |
callbacks=[checkpointer, tensorboard]).history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment