Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using multiple losses/datasets on the same model grows the update dictionary #71

Open
ppoulin91 opened this issue Feb 23, 2016 · 0 comments
Labels

Comments

@ppoulin91
Copy link
Contributor

In class Loss:

@property
def losses(self):
    """ Gets individual losses (one for each batch example). """
    if self._losses is None:
        model_output = self.model.get_output(self.dataset.symb_inputs)
        self._losses = self._compute_losses(model_output)

    return self._losses

Bug example:
# Get train losses
train_loss = DummyLoss(model, trainset)
train_losses = train_loss.losses

# Get valid losses
valid_loss = DummyLoss(model, validset)
valid_losses = valid_loss.losses

The call to train_loss.losses triggers model.get_output, using trainset.symb_inputs
The model updates dictionary contains elements specific to trainset.symb_inputs

The call to valid_loss.losses triggers again model.get_output, this time using validset.symb_inputs
The model will update the updates dictionary, which now contains elements specific to both trainset.symb_inputs and validset.symb_inputs

The easy fix would be to force models to replace the updates dictionary. However, it would be preferable to find a better way of managing the updates and losses

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant