A Layer by Hand
A linear layer with one output gives, for each row of x, the sum of that row's elements each multiplied by its weight in w, plus the bias b. Return its output for every row: a 1-D tensor.
Example 1
x [[1.0,2.0],[3.0,4.0]]
w [0.5,-1.0]
b 2.0
returns [0.5,-0.5]
Constraints
- 1 to 5 rows
whas one weight per column ofx
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Center the ColumnsEasy
- Daily ReturnsEasy
- End to EndEasy
- Floor at ZeroEasy
- Matrix Times MatrixEasy
- One HotEasy
- Only the PositivesEasy
- Rows That Sum to OneEasy