If you are passing in a single HxW grayscale image, you likely need to change it to NxCxHxW format (even if the batch size and the number of channels is 1). /
e.g., something like
feature = feature.unsqueeze(0).unsqueeze(0)