How it works...
We used nn.Sequential() from PyTorch to build the autoencoder by sequentially specifying the building blocks (nn.Module). Each pixel from a noisy image forms an input node, hence the input has 50*37 nodes. The output also has the same number of nodes.
A fully connected layer of size 1,850 x 512 was instantiated with nn.Linear(50*37, 512). nn.ReLU(True) was used to apply in-place ReLU non-linearity in between the input/hidden layers and nn.Sigmoid() before the final layer to apply the sigmoid function at the output layer. Binary cross-entropy loss was used with nn.BCEloss(). The backward() function was used to backpropagate and recompute the weights in the neural net.
We can run the code on a GPU by setting cuda = True
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access