I customize Trainer’s
compute_loss. Within the 'compute_loss`, I want to get two kinds of things from the model. The first kind is a config value, such as vocab_size. It is always a fixed value. The other kind are parameters, such as embeddings.
I find two models:
- self.model. I can get self.model.config.vocab_size and self.model.bert.embedding.word_embeddings.
model. In case of multi-gpu, I can’t access model.config.vocab_size and model.bert.embedding.word_embeddings because model is wrapped by ddp.
So what’s difference between self.model and model? How to get something from my model? Does self.model have up-to-date parameters?