pyepo.func.contrastive

Noise contrastive estimation loss function

Module Contents

Classes

NCE

An autograd module for noise contrastive estimation as surrogate loss

contrastiveMAP

An autograd module for Maximum A Posterior contrastive estimation as

class pyepo.func.contrastive.NCE(optmodel, processes=1, solve_ratio=1, reduction='mean', dataset=None)

Bases: pyepo.func.abcmodule.optModule

An autograd module for noise contrastive estimation as surrogate loss functions, based on viewing suboptimal solutions as negative examples.

For the NCE, the cost vector needs to be predicted from contextual data and maximizes the separation of the probability of the optimal solution.

Thus allows us to design an algorithm based on stochastic gradient descent.

Reference: <https://www.ijcai.org/proceedings/2021/390>

forward(pred_cost, true_sol)

Forward pass

class pyepo.func.contrastive.contrastiveMAP(optmodel, processes=1, solve_ratio=1, reduction='mean', dataset=None)

Bases: pyepo.func.abcmodule.optModule

An autograd module for Maximum A Posterior contrastive estimation as surrogate loss functions, which is an efficient self-contrastive algorithm.

For the MAP, the cost vector needs to be predicted from contextual data and maximizes the separation of the probability of the optimal solution.

Thus, it allows us to design an algorithm based on stochastic gradient descent.

Reference: <https://www.ijcai.org/proceedings/2021/390>

forward(pred_cost, true_sol)

Forward pass