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

How to use this siamese model for classification task? #66

Open
yuhengShii opened this issue Sep 2, 2021 · 0 comments
Open

How to use this siamese model for classification task? #66

yuhengShii opened this issue Sep 2, 2021 · 0 comments

Comments

@yuhengShii
Copy link

yuhengShii commented Sep 2, 2021

Hi,
If i have trained a siamese model, how can i use this model for my classification task?

Change the embedding_net into siamese_net and call its get_embedding to get feature vectors , is the following code correct? anticipating your reply.

siamese_net = EmbeddingNet()
class ClassificationNet(nn.Module):
    def __init__(self, siamese_net , n_classes):
        super(ClassificationNet, self).__init__()
        self.siamese_net = siamese_net 
        self.n_classes = n_classes
        self.nonlinear = nn.PReLU()
        self.fc1 = nn.Linear(2, n_classes)

  def forward(self, x):
      output = self.siamese_net.get_embedding (x)
      output = self.nonlinear(output)
      scores = F.log_softmax(self.fc1(output), dim=-1)
      return scores
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

1 participant