loss module

Full Documentation for hippynn.graphs.nodes.loss module. Click here for a summary page.

Nodes for constructing loss functions.

class MAELoss(predicted, true)[source]

Bases: _BaseCompareLoss

torch_module = LambdaModule(l1_loss)
class MSELoss(predicted, true)[source]

Bases: _BaseCompareLoss

torch_module = LambdaModule(mse_loss)
class Mean(parent)[source]

Bases: ReduceSingleNode

torch_module = LambdaModule(mean)
class MeanSq(parent)[source]

Bases: ReduceSingleNode

torch_module = LambdaModule(mean_sq)
class ReduceSingleNode(parent)[source]

Bases: SingleNode

classmethod of_node(node)[source]
class Rsq(predicted, true)[source]

Bases: _BaseCompareLoss

torch_module = RsqMod()
class RsqMod(*args, **kwargs)[source]

Bases: Module

forward(predicted, true)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Std(parent)[source]

Bases: ReduceSingleNode

torch_module = LambdaModule(std)
class Var(parent)[source]

Bases: ReduceSingleNode

torch_module = LambdaModule(var)
class WeightedMAELoss(predicted, true, weight)[source]

Bases: _WeightedCompareLoss

torch_module = WeightedMAELoss()
class WeightedMSELoss(predicted, true, weight)[source]

Bases: _WeightedCompareLoss

torch_module = WeightedMSELoss()
absolute_errors(predict: Tensor, true: Tensor)[source]

Compute the absolute errors with phases between predicted and true values. In other words, prediction should be close to the absolute value of true, and the sign does not matter.

Parameters:
  • predict (torch.Tensor) – predicted values

  • true (torch.Tensor) – true values

Returns:

errors

Return type:

torch.Tensor

l1reg(network)[source]
l2reg(network)[source]
lpreg(network, p)[source]
mean_sq(input)[source]