eduardoleao052 / js-pytorch

A JavaScript library like PyTorch, built from scratch.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example code still tries to use python syntax

dhenson02 opened this issue · comments

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.

Same issue in the examples further down the page.

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!