Open zinccat opened 1 year ago
Thanks for the report, I agree this is a bug. The get_num_losses
in domain uses the output names of each constraint to get a total number of losses.
The custom loss, particularly in the variational constraint does not give its output variables ahead of time and the variational constraint constructor will have 0 output keys (and thus say it has zero losses) since there are no output keys of a variational data set.
Unsure about a clean fix, without requiring additional user information its not possible presently to tell that a custom loss exists in this constraint without a forward pass. Example impacted.
The implementation of get_num_losses in
domain.py
is summing up the number of output names in constraints. Yet this is not the case when using custom loss function, e.g. when using variational constraint like the case in https://docs.nvidia.com/deeplearning/modulus/modulus-sym/user_guide/intermediate/variational_example.html