SciNim / flambeau

Nim bindings to libtorch
85 stars 3 forks source link

Fix mnist example with RawTensor and add tests for nn #27

Closed HugoGranstrom closed 3 years ago

HugoGranstrom commented 3 years ago

I've taken too long to get this done now... Mnist example works again but I will add some tests for nn in the coming days.

HugoGranstrom commented 3 years ago

I can't get nll_loss to run for some reason, it just gives me a SIGSEV: illegal memory access :/ Anyone have any ideas why?

Here's the docs for reference https://pytorch.org/cppdocs/api/function_namespacetorch_1_1nn_1_1functional_1a184d5fa95f2d4ba36538f3da6b10a7be.html#exhale-function-namespacetorch-1-1nn-1-1functional-1a184d5fa95f2d4ba36538f3da6b10a7be

machineko commented 3 years ago

I can't get nll_loss to run for some reason, it just gives me a SIGSEV: illegal memory access :/ Anyone have any ideas why?

Here's the docs for reference https://pytorch.org/cppdocs/api/function_namespacetorch_1_1nn_1_1functional_1a184d5fa95f2d4ba36538f3da6b10a7be.html#exhale-function-namespacetorch-1-1nn-1-1functional-1a184d5fa95f2d4ba36538f3da6b10a7be

I'm not good with C++ and stuff like this but log of 0 can crash it? (It was the case in tensorflow like ~4 years ago if i remember correctly📦 )

HugoGranstrom commented 3 years ago

@machineko Thank you for your suggestion :) It didn't turn out to be zero that was spooking around, it was the fact that target had to be of type int and not float. I tested the corresponding code in Pytorch and it immidietly yelled that at me. So lesson learned, next time I get a SIGSEV I'll try and see if Pytorch can give me a nice error message