-
Thank you for your excellent work. I want to ask for the best practices for the loss function. I have seen in the Get Start, the loss function is in the model class:
How should I separate the loss function and set it in the config just like mmdet?
What is the best practice for the position of the loss function in mmengine? I searched the documentation but couldn't find an answer. Could you please enlighten me? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Take an example from losses_cls = self.loss_cls(pred, gt)
return dict(loss_cls=losses_cls) |
Beta Was this translation helpful? Give feedback.
Take an example from
mmdet
:https://github.com/open-mmlab/mmdetection/blob/main/mmdet/models/dense_heads/anchor_head.py
Similarly, you can add
loss_cls
and more in your model__init__
func and useMODELS.build
to build the loss func from your config file, then in yourforward
function or somewhere else: