From aef1158187ddac5388574f693129d7d4e43093cc Mon Sep 17 00:00:00 2001 From: Marcus Edel Date: Sun, 3 Jan 2021 23:31:22 +0100 Subject: [PATCH] Add Deterministic() to the abstract layer class. --- src/mlpack/methods/ann/layer/layer.hpp | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/mlpack/methods/ann/layer/layer.hpp b/src/mlpack/methods/ann/layer/layer.hpp index e9e4519765..110a9ae849 100644 --- a/src/mlpack/methods/ann/layer/layer.hpp +++ b/src/mlpack/methods/ann/layer/layer.hpp @@ -142,6 +142,12 @@ class Layer */ virtual void Reset() {} + //! Get the model modules. + virtual std::vector*>& Model() + { + return model; + } + //! Get the parameters. virtual OutputType const& Parameters() const { return weights; } //! Modify the parameters. @@ -167,6 +173,21 @@ class Layer //! Modify the gradient. virtual OutputType& Gradient() { return gradient; } + /** + * Get the deterministic parameter. + * + * Mote: during training you should set the deterministic parameter for each + * layer to false and during testing you should set deterministic to true. + */ + virtual bool const& Deterministic() const { return deterministic; } + /** + * Modify the deterministic parameter. + * + * Mote: during training you should set the deterministic parameter for each + * layer to false and during testing you should set deterministic to true. + */ + virtual bool& Deterministic() { return deterministic; } + //! Get the layer loss. virtual double Loss() { return 0; } @@ -186,8 +207,14 @@ class Layer //! Locally-stored delta object. OutputType delta; + //! If true testing mode otherwise training mode. + bool deterministic; + //! Locally-stored gradient object. OutputType gradient; + + //! Locally-stored model. + std::vector*> model; }; #endif