Skip to content

Instantly share code, notes, and snippets.

@dansbecker
Created April 14, 2016 23:22
Show Gist options
  • Save dansbecker/67be6646f2fb8daa4856b61a9cb08366 to your computer and use it in GitHub Desktop.
Save dansbecker/67be6646f2fb8daa4856b61a9cb08366 to your computer and use it in GitHub Desktop.
Non-functioning autoencoder, with an error that surprises me.
import numpy as np
from keras.models import Model
from keras.layers import Input, Dense
input_size = 1000
n_obs = 200
encoding_size = 50
x = Input(shape=(input_size,))
z = Dense(encoding_size, activation='sigmoid', name='z')(x)
x_reconstruction = Dense(input_size, activation='sigmoid', name='x_reconstruction')(z)
model = Model(input=x, output=[z, x_reconstruction])
model.compile(loss = 'mse',
loss_weight = {'z': 0, 'x_reconstruction': 1},
optimizer='Adam')
data=np.random.rand(n_obs * input_size).reshape(n_obs, input_size)
#data = np.load('/Users/dan/Downloads/datarobot_text_features/datarobot_home_depot_search_term_features.npy')
model.fit(x = data, y = {'x_reconstruciton': data, 'z': np.zeros([n_obs, encoding_size])})
@dansbecker
Copy link
Author

Error is Exception: No data provided for input "x_reconstruction". Input data keys: dict_keys(['z', 'x_reconstruciton'])

@dansbecker
Copy link
Author

Was a typo in call to fit: x_reconstruciton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment