Two Layers
A network with two layers. The first turns each example x into h = relu(w1 · x + b1), and the second turns that into w2 · h + b2. Both weight tables have one row per output, as nn.Linear keeps them. Return the outputs for the examples in x, one row each.
Example 1
x [[1.0,-1.0]]
w1 [[1.0,0.0],[0.0,1.0]]
b1 [0.0,0.0]
w2 [[1.0,1.0]]
b2 [0.5]
returns [[1.5]]
Constraints
- 1 to 4 examples
- No layer has more than 4 inputs or outputs
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Two ParametersMedium
- Unit RowsMedium
- A Tiny NetworkHard
- Average the EmbeddingsHard
- Batch Norm by HandHard
- Clip the GradientHard
- Keep RollingHard
- Learning Rate StepsHard