I have trained a model with the following general architecture:
- Model takes two inputs
- Runs both of them through an embedding model, which returns some embedding corresponding to both inputs, say, shape a → [batch_size, 748] and b ->[batch_size, 748].
- Take the absolute difference, ie torch.abs(a - b), and pass to fully connected layer.
- Train model with cross entropy loss.
Now, I want to extract the embedding model such that I can pass one input and get an embedding. How can this be achieved?
The “forward hook” seems to not be applicable here since the number of inputs in my Siamese Network are two and thus I won’t be able to pass a single input and get the embedding.