Solved by mhubii in post #2 
              
              
                You forgot to register your submodules. Do the following, replace this line 
linear_1(torch::nn::LinearOptions(input, hidden)),
linear_2(torch::nn::LinearOptions(hidden, output))

by 
linear_1(register_module("linear_1", torch::nn::Linear(input, hidden))),
linear_2(register_module("linear_2", torch:…