0
0
PyTorchml~5 mins

Linear (fully connected) layers in PyTorch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a linear (fully connected) layer in a neural network?
A linear layer connects every input neuron to every output neuron with a weight. It performs a weighted sum of inputs plus a bias, producing outputs.
Click to reveal answer
beginner
How do you create a linear layer in PyTorch?
Use torch.nn.Linear(input_size, output_size). For example, torch.nn.Linear(10, 5) creates a layer with 10 inputs and 5 outputs.
Click to reveal answer
beginner
What are the learnable parameters in a linear layer?
The weights matrix and the bias vector. Weights connect inputs to outputs, and bias shifts the output values.
Click to reveal answer
intermediate
What is the shape of the weight matrix in a linear layer with input size 8 and output size 3?
The weight matrix shape is (3, 8). It has one row per output and one column per input.
Click to reveal answer
beginner
Why do we add a bias term in a linear layer?
Bias allows the model to shift the output up or down, helping it fit data better by not forcing the output to pass through zero.
Click to reveal answer
What does a linear layer do in a neural network?
AReduces the size of the input data by half
BComputes a weighted sum of inputs plus bias
CApplies a non-linear activation function
DNormalizes the input data
In PyTorch, which class creates a linear layer?
Atorch.nn.ReLU
Btorch.nn.Conv2d
Ctorch.nn.Linear
Dtorch.nn.BatchNorm1d
If a linear layer has input size 4 and output size 2, what is the shape of its weight matrix?
A(4, 2)
B(2, 2)
C(4, 4)
D(2, 4)
What is the role of the bias in a linear layer?
ATo shift the output values
BTo reduce overfitting
CTo normalize the output
DTo scale the inputs
Which of these is NOT true about linear layers?
AThey apply a non-linear activation by default
BThey include weights and bias parameters
CThey connect every input to every output
DThey perform a matrix multiplication
Explain how a linear (fully connected) layer transforms input data in a neural network.
Think about multiplying inputs by weights and adding bias.
You got /5 concepts.
    Describe how you would implement a linear layer in PyTorch and what parameters it needs.
    Focus on the class name and constructor arguments.
    You got /5 concepts.