Once the neural network layers have been defined we train the model by calling method
autoencoder.partial_fit(batch_xs) for each batch of data:
for epoch in range(training_epochs): avg_cost = 0. total_batch = int(n_samples / batch_size) # Loop over all batches for i in range(total_batch): batch_xs = get_random_block_from_data(X_train, batch_size) # Fit training using batch data cost = autoencoder.partial_fit(batch_xs) # Compute average loss avg_cost += cost / n_samples * batch_size # Display logs per epoch step if epoch % display_step == 0: print("Epoch:", '%04d' % (epoch + 1), "cost=", avg_cost)print("Total cost: " + str(autoencoder.calc_total_cost(X_test)))
The cost of each epoch is printed:
('Epoch:', '0001', 'cost=', ...