Ragnor
(Swap)
1
hello, i am trying to add implicit in my code
i want to convert imA into tensor but i got this error.
def forward(self, x):
_, _, H, W = x.size()
imA = torch.tensor(ImplicitA(channel=2048))
backbone_out = self.backbone(x) + imA()
segmentation_head_out = self.segmentation_head(backbone_out)
y = segmentation_head_out
return y
please help!
ptrblck
2
Could you describe what ImplicitA
is? Are you creating a new object and are trying to convert it to a tensor e.g. via:
class ImplicitA(object):
def __init__(self):
pass
torch.tensor(ImplicitA())
# > RuntimeError: Could not infer dtype of ImplicitA
Ragnor
(Swap)
3
yes.
i am using Implicit knowledge.
i make a class like
class ImplicitA(nn.Module):
def init(self, channel):
super(ImplicitA, self).init()
self.channel = channel
self.implicit = nn.Parameter(torch.zeros(1, channel, 1, 1))
nn.init.normal_(self.implicit, std=.02)
now i want to add my backbone output and implicit but I got that error.
ptrblck
6
I’m unsure what exactly you are trying to achieve, but you cannot transform an nn.Module
to a tensor via:
imA = torch.tensor(ImplicitA(channel=2048))
Ragnor
(Swap)
7
actually I solve this error.