Skip to content

New structure for loss #932

Closed
Closed

Description

@michaeldeistler
class Flow(DensityEstimator):
    def loss(self, input, condition):
        return self.log_prob(input, condition=condition)

    def log_prob(input, condition):
        return self.net.log_prob(input, condition)


class SNLEObjective(Objective):
    def __call__(net, theta, x):
        return net.loss(input=x, condition=theta)


def train(objective: Objective, net, theta, x, **objective_kwargs):
    ...
    loss_val = objective(net=net, theta=theta, x=x, **objective_kwargs)

Level 1: General across all methods.

Level 2: Loss of the method.

  • SNLE: net.loss(input=x, condition=theta)
  • SNPE: net.loss(input=theta, condition=x)
  • SNRE: net.loss(theta, x)

Level 3: .loss of the density estimator.

  • Flows: net.loss -> net.log_prob()
  • Diffusion: net.loss -> net.....()

Related to #922, #766

Activity

  1. self-assigned this
    on Feb 9, 2024
  2. added
    architecture
    on Feb 9, 2024
  3. linked a pull request that will close this issueDensity Estimator Class #952on Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

architecture

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions