i'm trying to create an autoencoder with keras, here's my code:
from keras import models, layers
from numpy import array
import random
data = array(
[array([[random.randint(0, 100) for i in range(50)]]) for i in range(500)]
).reshape((500, 50))
model = models.Sequential()
model.add(layers.Dense(input_dim=50, units=50, activation="sigmoid"))
model.add(layers.Dense(units=40, activation="sigmoid"))
model.add(layers.Dense(units=50, activation="sigmoid"))
model.compile(optimizer="adam", loss="mean_squared_error", metrics=["accuracy"])
model.fit(data, epochs=1)
and my error is :
Python\Python36\lib\site-packages\keras\engine\training_arrays.py", line 139, in fit_loop
if issparse(ins[i]) and not K.is_sparse(feed[i]):
IndexError: list index out of range
You forgot to provide the target data. In you case its the same as the input data, but you still need to tell keras that. This line should work:
model.fit(data, data, epochs=1)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments