I get a 1-D IntTensor,but i want to convert it to a integer. I try it by this method:
print(dictionary[IntTensor.int()])
but got an error:
You can use:
print(dictionary[IntTensor.data[0]])
The key you're using is an object of type autograd.Variable. .data gives the tensor and the index 0 can be used to access the element.
autograd.Variable
.data
0