virtual ~LearningRateScheduler() = default;
/**
+ * @brief Finalize creating the learning rate scheduler
+ *
+ * @details Verify that all the needed properties have been and within the
+ * valid range.
+ * @note After calling this it is not allowed to
+ * change properties.
+ */
+ virtual void finalize() = 0;
+
+ /**
* @brief get Learning Rate for the given iteration
* @param[in] iteration Iteration for the learning rate
* @retval Learning rate in double
ConstantLearningRateScheduler::ConstantLearningRateScheduler() :
lr_props(props::LearningRate()) {}
+void ConstantLearningRateScheduler::finalize() {
+ NNTR_THROW_IF(std::get<props::LearningRate>(lr_props).empty(),
+ std::invalid_argument)
+ << "[ConstantLearningRateScheduler] Learning Rate is not set";
+}
+
void ConstantLearningRateScheduler::setProperty(
const std::vector<std::string> &values) {
auto left = loadProperties(values, lr_props);
virtual double getLearningRate(size_t iteration) override;
/**
+ * @copydoc LearningRateScheduler::finalize()
+ *
+ */
+ virtual void finalize() override;
+
+ /**
* @copydoc LearningRateScheduler::exportTo(Exporter &exporter, const
* ExportMethods& method)
*
ExponentialLearningRateScheduler::ExponentialLearningRateScheduler() :
lr_props(props::DecayRate(), props::DecaySteps()) {}
+void ExponentialLearningRateScheduler::finalize() {
+ NNTR_THROW_IF(std::get<props::DecayRate>(lr_props).empty(),
+ std::invalid_argument)
+ << "[ConstantLearningRateScheduler] Decay Rate is not set";
+ NNTR_THROW_IF(std::get<props::DecaySteps>(lr_props).empty(),
+ std::invalid_argument)
+ << "[ConstantLearningRateScheduler] Decay Steps is not set";
+ ConstantLearningRateScheduler::finalize();
+}
+
void ExponentialLearningRateScheduler::setProperty(
const std::vector<std::string> &values) {
auto left = loadProperties(values, lr_props);
* @class Constant Learning Rate Scheduler class
* @brief class for constant Learning Rate Schedulers
*/
-class ExponentialLearningRateScheduler : public ConstantLearningRateScheduler {
+class ExponentialLearningRateScheduler final
+ : public ConstantLearningRateScheduler {
public:
/**
* @copydoc LearningRateScheduler::getLearningRate(size_t iteration) const
*
*/
- virtual double getLearningRate(size_t iteration) override;
+ double getLearningRate(size_t iteration) override;
+
+ /**
+ * @copydoc LearningRateScheduler::finalize()
+ *
+ */
+ void finalize() override;
/**
* @copydoc LearningRateScheduler::exportTo(Exporter &exporter, const