What's the corresponding function to torch.nn.CrossEntropyLoss() in C++ API?

I want to use torch.nn.CrossEntropyLoss to compute loss in C++, but I couldn’t find a corresponding function in C++ API, only binary_cross_entropy is found. Is there a function corresponding to torch.nn.CrossEntropyLoss?

I also could not find the function. Try the function below.
torch::nll_loss(out.log_softmax(1), targets);

Thanks for you advice!

1 Like

have you found the function?

Perhaps it was not available in 2019, but now I believe it is

https://pytorch.org/cppdocs/api/classtorch_1_1nn_1_1_cross_entropy_loss.html

I did not find the c++ source code