Question 1: Short answer
mediumAI-checkedExplainable AIWhat does this code print?
import torch
import torch.nn as nn
lin = nn.Linear(3, 2, bias=False)
with torch.no_grad():
lin.weight.copy_(torch.tensor([[1.0, -2.0, 0.5],
[0.3, 0.7, -1.5]]))
x = torch.tensor([[5.0, 1.0, 0.2]], requires_grad=True)
score = lin(x)[0, 1]
score.backward()
sal = x.grad.abs()
print(sal.argmax().item())