Getting the value at the intersection of a row and column in a pytorch tensor matrix
I am new to pytorch and am looking to get a value at an index from a matrix. There is a matrix called psfm_s that has been initialized with 
psfm_s=Var(torch.randn(12,20),requires_grad=True) For example, I would like to to get the number in the first column (out of 12 columns)  and the number in the first row (out of 20 rows).

I have tried doing something like index=torch.tensor([0,0])
num_at_index=psfm_s[index] to get the desired number but that just gets me a tensor with a bunch of numbers in it, I'm not really sure what happens with this method. 

I just want the one number at the desired index, how can I go about doing this if it's even possible? Thanks for the help!

To reproduce the described code in its completeness (for future reference, please provide a [mcve] in your question), and taking the already correct solution from @jodag in the comments, consider this code snippet:

from torch.autograd import Variable
import torch

psfm_s = Variable(torch.randn(12,20), requires_grad=True)
single_value = psfm_s[0,0].item()
print(single_value) # prints a single random number from your tensor


For some background information, consider the official docs:


  Returns the value of this tensor as a standard Python number. This
  only works for tensors with one element. For other cases, see tolist().
  
  This operation is not differentiable.


Consequently, getting a complete row (or column), would look like this:

from torch.autograd import Variable
import torch

psfm_s = Variable(torch.randn(12,20), requires_grad=True)
single_row_tensor = psfm_s[0,:]
single_row_list = single_row_tensor.tolist()
single_row_numpy_1 = single_row_tensor.data.numpy()
single_row_numpy_2 = single_row_tensor.detach().numpy()

# the following doesn't work, as it is a torch.Variable with gradient history:
single_row_fail = single_row_tensor.numpy()


In the case you want to get a NumPy array, you have to be careful not to directly cast it to .numpy(), as this causes issues with the gradient history of the Variable. You can either use .data.numpy(), or .detach().numpy(). 
There seems to be some discussion as to which one is preferred, but both should work for your case.
