vvanirudh:

association = torch.mv(hidden_states_other[l], hidden_states[i])
probs = torch.nn.functional.softmax(association)
attention_val = torch.mv(torch.t(hidden_states_other[l]), probs)
hidden_states_weights[i] = attention_val


It couldn’t have been that, since if I replace the above snippet with this
# association = torch.mv(hidden_states_other[l], hidden_states[i])
# probs = torch.nn.functional.softmax(association)
probs = Variable(torch.ones(torch.numel(l)).cuda())
attention_val = torch.mv(torch.t(hidden_states_other[l]), probs)
hidden_states_weights[i] = attention_val

It works without any error.