Many Outputs
nn.Linear keeps its weights as a table with one row per output. Given such a table w, a bias b with one number per output, and inputs x with one row per example, return the outputs of the layer: for each example and each output, the dot product of the example with that output's row of w, plus that output's bias.
Example 1
x [[1.0,2.0]]
w [[1.0,0.0],[0.0,1.0],[1.0,1.0]]
b [0.0,0.0,10.0]
returns [[1.0,2.0,13.0]]
Constraints
- 1 to 4 examples, 1 to 3 inputs, 1 to 3 outputs
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Mean Squared ErrorMedium
- One Step DownhillMedium
- Two LayersMedium
- Two ParametersMedium
- Unit RowsMedium
- A Tiny NetworkHard
- Average the EmbeddingsHard
- Batch Norm by HandHard