dice_loss.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTIONS_DICE_LOSS_HPP
13 #define MLPACK_METHODS_ANN_LOSS_FUNCTIONS_DICE_LOSS_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace ann {
19 
46 template <
47  typename InputDataType = arma::mat,
48  typename OutputDataType = arma::mat
49 >
50 class DiceLoss
51 {
52  public:
58  DiceLoss(const double smooth = 1);
59 
67  template<typename PredictionType, typename TargetType>
68  typename PredictionType::elem_type Forward(const PredictionType& prediction,
69  const TargetType& target);
70 
79  template<typename PredictionType, typename TargetType, typename LossType>
80  void Backward(const PredictionType& prediction,
81  const TargetType& target,
82  LossType& loss);
83 
85  OutputDataType& OutputParameter() const { return outputParameter; }
87  OutputDataType& OutputParameter() { return outputParameter; }
88 
90  double Smooth() const { return smooth; }
92  double& Smooth() { return smooth; }
93 
97  template<typename Archive>
98  void serialize(Archive& ar, const uint32_t /* version */);
99 
100  private:
102  OutputDataType outputParameter;
103 
105  double smooth;
106 }; // class DiceLoss
107 
108 } // namespace ann
109 } // namespace mlpack
110 
111 // Include implementation.
112 #include "dice_loss_impl.hpp"
113 
114 #endif
The dice loss performance function measures the network&#39;s performance according to the dice coefficie...
Definition: dice_loss.hpp:50
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Backward(const PredictionType &prediction, const TargetType &target, LossType &loss)
Ordinary feed backward pass of a neural network.
double & Smooth()
Modify the smooth.
Definition: dice_loss.hpp:92
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: dice_loss.hpp:85
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
double Smooth() const
Get the smooth.
Definition: dice_loss.hpp:90
DiceLoss(const double smooth=1)
Create the DiceLoss object.
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the dice loss function.
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: dice_loss.hpp:87