Class ComposedLoss

Inheritance Relationships

Base Type

  • public fuse_core::Loss

Class Documentation

class ComposedLoss : public fuse_core::Loss

The ComposedLoss loss function.

This class encapsulates the ceres::ComposedLoss class, adding the ability to serialize it and load it dynamically.

See the Ceres documentation for more details: http://ceres- solver.org/nnls_modeling.html::lossfunction

Public Functions

explicit ComposedLoss(const std::shared_ptr<fuse_core::Loss> &f_loss = nullptr, const std::shared_ptr<fuse_core::Loss> &g_loss = nullptr)

Constructor.

Parameters:
  • f_loss[in] The ‘f’ loss function, which is evaluated last to yield the composition ‘f(g(s))’. If it is nullptr the fuse_loss::TrivialLoss is used. Defaults to nullptr.

  • g_loss[in] The ‘g’ loss function, which is evaluated first to yield the composition ‘f(g(s))’. If it is nullptr the fuse_loss::TrivialLoss is used. Defaults to nullptr.

~ComposedLoss() override = default

Destructor.

virtual void initialize(fuse_core::node_interfaces::NodeInterfaces<fuse_core::node_interfaces::Base, fuse_core::node_interfaces::Logging, fuse_core::node_interfaces::Parameters> interfaces, const std::string &name) override

Perform any required post-construction initialization, such as reading from the parameter server.

This will be called on each plugin after construction.

Parameters:
  • interfaces[in] - The node interfaces used to load the parameter

  • name[in] A unique name to initialize this plugin instance, such as from the parameter server.

virtual void print(std::ostream &stream = std::cout) const override

Print a human-readable description of the loss function to the provided stream.

Parameters:

stream[out] The stream to write to. Defaults to stdout.

virtual ceres::LossFunction *lossFunction() const override

Return a raw pointer to a ceres::LossFunction that implements the loss function.

The Ceres interface requires a raw pointer. Ceres will take ownership of the pointer and promises to properly delete the loss function when it is done. Additionally, Fuse promises that the Loss object will outlive any generated loss functions (i.e. the Ceres objects will be destroyed before the Loss Function objects). This guarantee may allow optimizations for the creation of the loss function objects.

Returns:

A base pointer to an instance of a derived ceres::LossFunction.

inline std::shared_ptr<fuse_core::Loss> fLoss() const

Parameter ‘f_loss’ accessor.

Returns:

Parameter ‘f_loss’.

inline std::shared_ptr<fuse_core::Loss> gLoss() const

Parameter ‘g_loss’ accessor.

Returns:

Parameter ‘g_loss’.

inline void fLoss(const std::shared_ptr<fuse_core::Loss> &f_loss)

Parameter ‘f_loss’ mutator.

Parameters:

loss[in] Parameter ‘f_loss’.

inline void gLoss(const std::shared_ptr<fuse_core::Loss> &g_loss)

Parameter ‘g_loss’ mutator.

Parameters:

loss[in] Parameter ‘g_loss’.

Friends

friend class boost::serialization::access