SEG-GRAD-CAM
SEG-GRAD-CAM copied to clipboard
Error of a layer with multi input
I want to draw a heatmap for "Attention UNet", which has attention gate need two input. When code run the loop in class FeatureExtractor:
for name, module in self.model._modules.items():
x = module(x)
if name in self.target_layers:
x.register_hook(self.save_gradient)
outputs += [x]
when it run to attention gate:
TypeError: forward() missing 1 required positional argument: 'x'
Code of attunet is:
def forward(self, x):
e1 = self.inc(x)
e2 = self.down1(e1)
e3 = self.down2(e2)
e4 = self.down3(e3)
e5 = self.down4(e4)
d4 = self.Up4(e5)
x4 = self.Att4(g=d4, x=e4) #Error happened
……
How to make the code support this network?Hope your reply.
Has your problem been solved? I also encountered a similar problem. Thank you!
I want to draw a heatmap for "Attention UNet", which has attention gate need two input. When code run the loop in class FeatureExtractor:
for name, module in self.model._modules.items(): x = module(x) if name in self.target_layers: x.register_hook(self.save_gradient) outputs += [x]
when it run to attention gate:
TypeError: forward() missing 1 required positional argument: 'x'
Code of attunet is:
def forward(self, x): e1 = self.inc(x) e2 = self.down1(e1) e3 = self.down2(e2) e4 = self.down3(e3) e5 = self.down4(e4) d4 = self.Up4(e5) x4 = self.Att4(g=d4, x=e4) #Error happened ……
How to make the code support this network?Hope your reply.
Has your problem been solved? I also encountered a similar problem. Thank you!