Hello! I want to know how to add nn.Embedding type variables to model’s parameters. My model is defined as below:
class Model(nn.Module):
    def __init__(self, a, b, hops):
        self.W1 = torch.nn.Embedding(a, b)
        self.W2 = torch.nn.Embedding(a, b)
        self.R_list = []
        for i in range(hops):
            R_list.append(torch.nn.Embedding(a, b))

When I check model.parameters(), only W1 and W2. are outputed, which means that R are not in model.paremeters. So I want to know how to add them. Thanks!!

I know torch.nn.Parameter() can put Tensor type in the model’s parameter.