Hello!
I am trying to convert an std::vector to torch:Tensor with the following code:

torch::Tensor next_state = torch::from_blob(replay_memory.at(trainingIDX + 1).current_state.data(), { k_input_size_ }).to(*device);

However, I have done some troubleshooting since my traning loop which uses this tensor crashes since it han nan values in it.
So I tried:

std::cout << replay_memory.at(trainingIDX+1).current_state << std::endl;
torch::Tensor next_state = torch::from_blob(replay_memory.at(trainingIDX + 1).current_state.data(), { k_input_size_ }).to(*device);
std::cout << "next state is: " << next_state << std::endl;

Which at the iteration of the crash gives me:

0.0642382 0.0395936 0 0.219108 0.372894 0.422909 0.554452 0.302765 1
next state is: -1.7024e+35
1.3785e+00
-6.2066e+14
1.2834e+00
0.0000e+00
0.0000e+00
-1.0163e+17
1.5941e+00
nan

Note that:

torch::Tensor current_state = torch::tensor(replay_memory.at(trainingIDX).current_state).to(*device);

Gives me a tensor that looks the way I want it but then the program crashes when I try to feed it through the network, an issue I did not have with from_blob…