Run the same gradcheck on float32 copies of a and b. What does it return?
Pick one to see what it prints.
It fails after a warning.
2-D shapes
Nudge
Error in each slope
gradcheck
float32
1e-6
up to 0.3
fails, 5 seeds of 5
float64
1e-6
under 1e-9
passes
Near 1, float32 stores numbers in steps of about 1.2×10−7. A nudge of 10−6 moves an output by only about 8 of those steps, so the central difference keeps a digit or two.
The gradcheck docs say the same: its defaults are built for double precision, and float32 input will likely fail.
When it fails, the message names the input
This is the start of the message for the mean bug from Part 3, trimmed to fit:
GradcheckError: Jacobian mismatch for output 0 with respect to input 1,numerical:tensor([[-2.3104, 0.0000, 0.0000, 0.0000, 0.0000, ......analytical:tensor([[-1.1552, 0.0000, 0.0000, 0.0000, 0.0000, ...
It names the output and the input where the two Jacobians disagree, then prints both. Input 1 is b. Every analytical entry is half its numerical twin, which is the mean over a batch of 2.
In the editor, write passes(dtype): the same correct MatMul through gradcheck in float64 and in float32.
Pick an answer above to see the rest
Instructions
1
Write passes(dtype): run gradcheck on MatMul.apply with a and b turned into dtype, and return whether it passed.
2
a and b are in the editor. Pass raise_exception=False.