But what is linear layer?

Hi I am trying to understand fundamentals of PyTorch and ML and I want to ask you.
For example lets think code like this -
I create x and put that x into linear layer. What is happening with this x ?
When I print y it is equal to some random numbers.
Can someone give me hint about this ? And maybe when should I use lienar layer ?

x = torch.randn((2, 2))
in_features = 2
out_features = 16

m = torch.nn.Linear(in_features, out_features)

y = m(x)

A linear layer is a MLP layer. (Multi layer perceptron)

Have a look at this video:

Can you give example on what kind of problem would you use linear layer ? Only one linear layer. No network. Some kind of problem and its solution with linear layer.

EDIT: This video is nice for sure but it do not answer question I think.

Currently i’m using a linear layer in a project for classification with a CNN.
Screenshot from 2021-08-10 21-20-52

This one use case where linear layers are used for classification after feature extraction. There may be more problems in which linear layers can be used but it depends on what you’re working on.

1 Like