I'm trying to create an Autoencoder neural network for finding outliers using Keras TensorFlow, my data is a list of texts with one word per line, it is the following: https://pastebin.com/hEvm6qWg it has 139 lines.
When I fit my model with my data, I get the error:
ValueError: Error when checking input: expected input_1 to have shape (139,) but got array with shape (140,)
But I can't tell why it recognizes it as 140 shape array, my entire code is as follows:
from keras import Input, Model
from keras.layers import Dense
from keras.preprocessing.text import Tokenizer
with open('drawables.txt', 'r') as arquivo:
dados = arquivo.read().splitlines()
tokenizer = Tokenizer(filters='')
tokenizer.fit_on_texts(dados)
x_dados = tokenizer.texts_to_matrix(dados, mode="freq")
tamanho = len(tokenizer.word_index)
x = Input(shape=(tamanho,))
# Encoder
hidden_1 = Dense(tamanho, activation='relu')(x)
h = Dense(tamanho, activation='relu')(hidden_1)
# Decoder
hidden_2 = Dense(tamanho, activation='relu')(h)
r = Dense(tamanho, activation='sigmoid')(hidden_2)
autoencoder = Model(input=x, output=r)
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(x_dados, epochs=5, shuffle=False)
I am utterly lost, I can't even tell if my approach to an autoencoder network is the correct one, what am I doing wrong?