A linear (fully connected) layer is the most fundamental building block in neural networks. It transforms an input by multiplying with a weight matrix and adding a bias vector. This operation is also called a dense layer or an affine transformation.
Given an input matrix X (n samples, d_in features), a weight matrix W (d_in x d_out), and a bias vector b (d_out), compute the linear layer output.
Where b is broadcast (added to every row of XW).
Return an n by d_out list containing XW plus the broadcast bias.
Input: X = [[1, 2], [3, 4]], W = [[1, 0], [0, 1]], b = [0, 0]
Output: [[1, 2], [3, 4]]
Explanation: Identity weights and zero bias leave every row unchanged.
Input: X = [[1, 2]], W = [[1], [2]], b = [3]
Output: [[8]]
Compute each output entry from one row of X and one column of W.
Add the corresponding bias value after the inner dot product.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: array
A linear (fully connected) layer is the most fundamental building block in neural networks. It transforms an input by multiplying with a weight matrix and adding a bias vector. This operation is also called a dense layer or an affine transformation.
Given an input matrix X (n samples, d_in features), a weight matrix W (d_in x d_out), and a bias vector b (d_out), compute the linear layer output.
Where b is broadcast (added to every row of XW).
Return an n by d_out list containing XW plus the broadcast bias.
Input: X = [[1, 2], [3, 4]], W = [[1, 0], [0, 1]], b = [0, 0]
Output: [[1, 2], [3, 4]]
Explanation: Identity weights and zero bias leave every row unchanged.
Input: X = [[1, 2]], W = [[1], [2]], b = [3]
Output: [[8]]
Compute each output entry from one row of X and one column of W.
Add the corresponding bias value after the inner dot product.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: array