Loss module

class loss.OZELoss(reduction='mean', alpha=0.3)

Bases: Module

Custom loss for TRNSys metamodel.

Compute, for temperature and consumptions, the intergral of the squared differences over time. Sum the log with a coeficient alpha.

\[ \begin{align}\begin{aligned}\Delta_T = \sqrt{\int (y_{est}^T - y^T)^2}\\\Delta_Q = \sqrt{\int (y_{est}^Q - y^Q)^2}\\loss = log(1 + \Delta_T) + \alpha \cdot log(1 + \Delta_Q)\end{aligned}\end{align} \]

Parameters:

alpha:

Coefficient for consumption. Default is 0.3.

forward(y_true, y_pred)

Compute the loss between a target value and a prediction.

Parameters
  • y_true (Tensor) – Target value.

  • y_pred (Tensor) – Estimated value.

Return type

Tensor

Returns

Loss as a tensor with gradient attached.