Hello,
In Pytorch/Python I am generating Resnet34 feature vectors,e.g. a vector of size 512 for a single image which I normalise using:
numpy.linalg.norm.
What is the equivalent form in libtorch? This (libtorch 1.2) does not seem to work.
torch::Tensor out_tensor = module.forward({input_tensor}).toTensor();
const auto dimensions = out_tensor.ndimension();
const auto v_size = out_tensor.size(1); //Should be 512
//std::cout << out_tensor.norm().item() <<std::endl;
std::cout << torch::norm(out_tensor) <<std::endl;

The code in PyTorch:
f =features[i].cpu().detach().numpy()
f= f / np.linalg.norm(f)

Thanks,