How to separate losses of the same quantity

Hi,
I have two loss terms associated with the same quantity v. The one is the symmetry boundary, where v=0. The other is the PointwiseConstraint used to perform inversion, where v=v_data. In the losses.items(), it seems these two losses are combined automatically as loss_v. I am wondering how to separate them.

Thanks a lot.

Hi @zhangzhenthu

That is correct, modulus combines the logging of losses when the variable is the same. The idea here is to show the logs between the different variables losses to understand how the convergence of each output state variable is balanced.

Unfortunately to change this functionality needs some editing to the source code. I have not tried this myself, but the loss keys/names are assigned here in the domain.py file. One could try modifying this to be something like:

for key, constraint in self.constraints.items():
    for loss_key, value in constraint.loss(step).items():
        if loss_key not in list(losses.keys()):
            losses[key + "_" + loss_key] = value
        else:
            losses[key + "_" +loss_key] += value 

which should hopefully log each loss of each constraint uniquely. See the install from source steps for some info of how to install from the source code if you are not too familiar with developing python packages.

Hi, thank you for your help. It works well.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.