I have to use a tied weight between an Embedding layer and a linear layer
emb_mod = nn.Embedding(input_size, emb_size)
linear_mod = nn.Linear(emb_size, input_size)
When I tried to do
linear_mod.weight = torch.transpose(emb_mod.weight, 0, 1)
It returned error saying torch.transpose(emb_mod.weight, 0, 1) is a Variable, no longer a nn.Parameter, however linear_mod.weight only accept Parameter assignment.
How can I achive this weight tying? Thanks