PyTorch C++ neural network output given as a product of two numbers

Hi. I just started using PyTorch C++ fully. I set up a simple neural network that can evaluate a given tensor. When evaluating the neural network, the output (which I set to be a scalar, for only one input in this case) is shown as follows:

To test whether this output was a scalar Tensor (or a symbolic thing), I instead outputted this output plus a c++ float, and the result was then a correct scalar Tensor being shown with one number. Does anyone know why C++ by default shows the output in this format?

Thank you.

Hi @ptrblck, apologies for tagging you promptly here. Do you happen to know of this behavior or know someone who can help me understand this. Thank you.

I’m not sure which formats you are comparing, but they are defined here in case you want to check it.

Thank you. I see at the end of the function that it returns return std::make_tuple(scale, sz); a scale and a size in a tuple. This shouldn’t affect any arithmetic operations one would do with tensors, right?

Yes, this won’t change the internal value but just formats it for easier readability during printing.

1 Like