How to call MSE_loss

This looks like it should be right to me:

torch::Tensor loss = torch::mse_loss(prediction, desired_prediction.detach(), torch::nn::functional::MSELossFuncOptions(torch::kNone));

But I’m getting

error: cannot convert ‘torch::nn::functional::MSELossFuncOptions {aka torch::nn::MSELossOptions}’ to ‘int64_t {aka long int}’ for argument ‘3’ to ‘at::Tensor at::mse_loss(const at::Tensor&, const at::Tensor&, int64_t)

I’m sure it’s a simple thing - any idea what’s wrong?

Changing torch::mse_loss to torch::nn::functional::mse_loss should make it work.

mse_loss is defined under torch::nn::functional namespace.

1 Like

It gives me an error saying :

error: ‘functional’ is not a namespace-name

And if I go to its definition it gets me to the thrust API. What could be wrong?