February 2018
Intermediate to advanced
262 pages
6h 59m
English
It is a common practice to use a fully connected, or linear, layer at the end of most networks for an image classification problem. We are using a two-dimensional convolution that takes a matrix of numbers as input and outputs another matrix of numbers. To apply a linear layer, we need to flatten the matrix which is a tensor of two-dimensions to a vector of one-dimension. The following example will show you how view works:

Let's look at the code used in our network that does the same:
x.view(-1, 320)
As we saw earlier, the view method will flatten an n-dimension tensor to a one-dimensional tensor. In our network, the first dimension ...