karpathy / nn-zero-to-hero

Neural Networks: Zero to Hero
MIT License
11.63k stars 1.46k forks source link

added rsub to allow MSE calc in any order #4

Open machinatoonist opened 2 years ago

machinatoonist commented 2 years ago

I was following along with your video but reversed the order when calculating MSE and produced a TypeError: unsupported operand type(s) for -: 'float' and 'Value' .

Because of your instructions about adding rmul in the Value class I realised how this might be fixed so subtraction order doesn't matter.

def rsub(self, other): # other - self return self - other