Basic autoencoders
Let's look at a basic example of an autoencoder that also happens to be a basic autoencoder. First, we will create an AutoEncoder
class and initialize it with the following parameters passed to __init__()
:
num_input
: Number of input samplesnum_hidden
: Number of neurons in the hidden layertransfer_function=tf.nn.softplus
: Transfer functionoptimizer = tf.train.AdamOptimizer()
: Optimizer
Note
You can either pass a custom transfer_function
and optimizer
or use the default one specified. In our example, we are using softplus as the default transfer_function
(also called activation function): f(x)=ln(1+ex)
.
Autoencoder initialization
First, we initialize the class variables and weights:
self.num_input = num_input self.num_hidden = num_hidden self.transfer = transfer_function network_weights = self._initialize_weights() self.weights = network_weights
Here, the _initialize_weigths()
function is a local function that initializes values for the weights
dictionary:
w1
is a 2D tensor...