That is so confusing to me! Can a friend help me?
Based on the error message it seems you are trying to replace a registered nn.Module
with a tensor, which won’t work:
class MyModel(nn.Module):
def __init__(self):
super().__init__()
self.relation_embeddings = nn.Embedding(10, 10)
model = MyModel()
model.relation_embeddings = torch.randn(1)
# TypeError: cannot assign 'torch.FloatTensor' as child module 'relation_embeddings' (torch.nn.Module or None expected)
Either replace it with another module or delete it by setting it to None
.