Named tensors Warning

Hi, please give me some advice.

This warning below is always occur when I run my test code.

UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at …\c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)

The recognition results seem not weird, so probably this error is not affecting the processing at this moment, but I am curious if it is 100% ok or not.

I have found a doc related to named_tensor in the link below:
https://pytorch.org/docs/stable/named_tensor.html

I am not using any methods related to tensor name in my code, so it’s hard to find why this warning occur.

Below is my code for test:

test_transforms = transforms.Compose([transforms.Resize((224,224)),
                                      transforms.ToTensor(),
                                      transforms.Lambda(lambda x: x.repeat(3, 1, 1)),
                                      transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
                                      ])
real = Image.open(image)
inputimage = test_transforms(real).unsqueeze_(0)
img_variable = Variable(inputimage)
img_variable = img_variable.to(device)
output = model(img_variable)
stm = nn.Softmax(dim=1)
1 Like

I think you can ignore it for now and either install the nightly release or wait for the next stable release as the issue was tracked and fixed here.

1 Like

@ptrblck
Thank you for your kind reply!
But the warning message makes me nervous.
Is there anything I can do to check if there actually is any problem related this or not?
What kind of error could be possible do you think if it happended?

/opt/conda/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /pytorch/c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)

I am getting the above error and its effecting my output, I should get plots of model execution time but was unsuccessful. Could someone help me in resolving this issue. Thanks in advance.

You are seeing a warning, not an error, which should not influence any results.
The warning spamming is a known issue and was tracked here and already fixed. You could update PyTorch to the latest stable or nightly release to get rid of this warning.

2 Likes