Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Before proto #5

Open
wwx13 opened this issue Aug 20, 2022 · 1 comment
Open

Before proto #5

wwx13 opened this issue Aug 20, 2022 · 1 comment

Comments

@wwx13
Copy link

wwx13 commented Aug 20, 2022

Hi!
Sorry, i have too many questions bother you....

class LTA(nn.Module):
  def forward(self, *input):

      elif type == 'proto_adapt':
                  unseen_protos, seen_y = input[:-1]
      
                  device = unseen_protos.device
                  before_protos = torch.zeros(len(self.seen_class_protos), self.emb_size).to(device)
                  for i, x in enumerate(self.seen_class_protos):
                      before_protos[i] = self.seen_class_protos[i]  # matrix S
                  seen_protos = before_protos[seen_y]  # matrix S_i
      
                  protos = torch.cat([seen_protos, unseen_protos], 0)  # matrix R

Why we need before_protos? Can we use torch.select(self.seen_class_protos, seen_y to replace above codes?

@Quareia
Copy link
Owner

Quareia commented Aug 20, 2022

I met some back propagation wrong when indexing/slicing on nn.ParameterList, maybe torch.select can do it~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants