eduardoleao052 / js-pytorch

A JavaScript library like PyTorch, with GPU acceleration.
https://eduardoleao052.github.io/js-pytorch/site/index.html
MIT License
1.05k stars 37 forks source link

Example code still tries to use python syntax #4

Closed dhenson02 closed 6 months ago

dhenson02 commented 6 months ago

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.

eduardoleao052 commented 6 months ago

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!