While this isn't literally invalid as JS (assuming requires_grad exists already and is not a constant), the example should be tailored to the new language it's in.
w = torch.randn([8,5,4], requires_grad = true);
b = torch.tensor([0.2, 0.5, 0.1, 0.0], requires_grad = true);
Should replace requires_grad = true with true
Also bad practice (and invalid with strict mode) to create implicit globals like this w = .... Instead, add const, let or var beforehand to fix.
Thanks for pointing it out! With the variable declarations inside the function calls, it's a lot clearer to actually show what "true" is referring to, but it's not proper JS. Thanks!
While this isn't literally invalid as JS (assuming
requires_grad
exists already and is not a constant), the example should be tailored to the new language it's in.Should replace
requires_grad = true
withtrue
Also bad practice (and invalid with strict mode) to create implicit globals like this
w = ...
. Instead, addconst
,let
orvar
beforehand to fix.Same issue in the examples further down the page.