I try to double layer GAT for this code:
class AntispoofModel(nn.Module):
def __init__(self, device="cpu", **kwargs):
super().__init__()
resnet = torch.hub.load('pytorch/vision:v0.10.0', 'resnet18', pretrained=True)
self.resnet = nn.Sequential(*[i for i in list(resnet.children())[:-2]]).to(device)
for ch in self.resnet.children():
for param in ch.parameters():
param.requires_grad = False
self.gat = GAT(**kwargs).to(device)
self.device = device
self.adj = torch.tensor(grid_to_graph(3, 3, return_as=np.ndarray)).to(device)
def forward(self, x):
x = self.resnet(x.to(self.device))
x = nn.functional.avg_pool2d(x, 2)
x = x.view(-1, 9, 512)
#adj = torch.stack([self.adj for i in range(x.shape[0])]).to(self.device)
x = self.gat(x, self.adj)
return torch.sigmoid(x)
As I understand I just need to add line x = self.gat(x, self.adj)
somewhere else. But I don’t understand where (start/middle/end). Can someone help, please?
I use ’ GitHub - Diego999/pyGAT: Pytorch implementation of the Graph Attention Network model by Veličković et. al (2017, https://arxiv.org/abs/1710.10903)’