Setting up a regularized autoencoder
A regularized autoencoder extends the standard autoencoder by adding a regularization parameter to the cost
function.
Getting ready
The regularized autoencoder is an extension of the standard autoencoder. The set-up will require:
- TensorFlow installation in R and Python.
- Implementation of a standard autoencoder.
How to do it...
The code setup for the autoencoder can directly be converted to a regularized autoencoder by replacing the cost definition with the following lines:
Lambda=0.01 cost = tf$reduce_mean(tf$pow(x - y_pred, 2)) Regularize_weights = tf$nn$l2_loss(weights) cost = tf$reduce_mean(cost + lambda * Regularize_weights)
How it works...
As mentioned earlier, a regularized autoencoder extends the standard autoencoder by adding a regularization parameter to the cost function, shown as follows:
Here, λ is the regularization parameter and i and j are the node indexes with W representing the hidden layer weights for the autoencoder. The regularization autoencoder...