I trained a stacked denoising autoencoder with keras. Every thing was fine until it comes to predict new samples. The samples for prediction are named 'active' part, I did the necessary pre-processing and normalization to this part as I did to the training part and I added a noise to it the same way.
here is the denoising autoencoder:
checkpointer = ModelCheckpoint(filepath="modelyes.h5",
verbose=0,
save_best_only=True,
save_weights_only=True)
tensorboard = TensorBoard(log_dir='/tmp/autoencoder',
histogram_freq=0,
write_graph=True,
write_images=True)
input_enc = Input(shape=(input_size,))
hidden_1 = Dense(hidden_size1, activation='relu')(input_enc)
hidden_11 = Dense(hidden_size2, activation='relu')(hidden_1)
code = Dense(code_size, activation='relu')(hidden_11)
hidden_22 = Dense(hidden_size2, activation='relu')(code)
hidden_2 = Dense(hidden_size1, activation='relu')(hidden_22)
output_enc = Dense(input_size, activation='tanh')(hidden_2)
D_autoencoder_yes = Model(input_enc, output_enc)
D_autoencoder_yes.compile(optimizer='adam',
loss='mean_squared_error',
metrics=['accuracy'])
history_D_yes = D_autoencoder_yes.fit(df_noised_noy_norm_y, df_noyau_norm_y,
epochs=200,
batch_size=batch_size,
shuffle = True,
validation_data=(df_noised_test_norm_y, df_test_norm_y),
verbose=1,
callbacks=[checkpointer, tensorboard]).history
D_autoencoder_yes.save_weights("modelyes.h5")
D_autoencoder_yes.load_weights("modelyes.h5")
And here is the prediction script:
predicted_active = D_autoencoder_yes.predict(df_noised_active_norm)
print(predicted_active.tolist())
And here is how I added noise to the active part:
mu, sigma = 2, 3
np.random.seed(42)
noise_active = np.random.normal(mu, sigma, [10000,48])
noised_active = df_active + noise_active
The generated ERROR :
ValueError: Input contains NaN, infinity or a value too large for dtype('float64')
I did the pre-processing to the active part but I didn't understand where is the problem.