int setOptimizer(std::shared_ptr<Optimizer> opt);
/**
+ * @brief Get the Optimizer object
+ *
+ * @return std::shared_ptr<Optimizer> optimizer
+ */
+ std::shared_ptr<Optimizer> getOptimizer() { return opt; }
+
+ /**
* @brief Activation Type Getter
* @retval Activation Type.
*/
return weight_list.get()[position];
}
+ /**
+ * @brief Get the number of weights
+ *
+ * @return unsigned int number of weights
+ */
+ unsigned int getNumWeights() { return num_weights; }
+
#if defined(ENABLE_TEST)
/**
* @brief Set the batch for the layer
}
/**
- * @brief Get the number of weights
- *
- * @return unsigned int number of weights
- */
- unsigned int getNumWeights() { return num_weights; }
-
- /**
* @brief weight_list in this layer. This contains trainable weights of
* layers.
*/
*/
void setType(LayerType type) { this->type = type; }
+ /**
+ * @brief Activation Setter
+ * @param[in] activation activation type
+ * @throw std::invalid_argument when ActivationType is unknown
+ */
+ virtual void setActivation(ActivationType activation);
+
private:
/**
* @brief Set containing all the names of layers
virtual void printMetric(std::ostream &out);
/**
- * @brief Activation Setter
- * @param[in] activation activation type
- * @retval #ML_ERROR_NONE Successful.
- * @retval #ML_ERROR_INVALID_PARAMETER invalid parameter.
- */
- int setActivation(ActivationType activation);
-
- /**
* @brief set weight decay parameters
* @param[in] w struct for weight decay
*/
* @param[in] ActivationType ActivationType ActivationType to be set
*/
void ActivationLayer::setActivation(ActivationType acti_type) {
+ Layer::setActivation(acti_type);
+
switch (acti_type) {
case ActivationType::ACT_TANH:
this->setActivation(tanhFloat, tanhPrime);
default:
throw std::runtime_error("Error: Not Supported Activation Type");
}
- this->activation_type = acti_type;
}
Tensor ActivationLayer::softmax(Tensor const &t) {
namespace nntrainer {
-int Layer::setActivation(ActivationType acti) {
- int status = ML_ERROR_NONE;
+void Layer::setActivation(ActivationType acti) {
if (acti == ActivationType::ACT_UNKNOWN) {
- ml_loge("Error:have to specify activation function");
- return ML_ERROR_INVALID_PARAMETER;
+ throw std::invalid_argument("Error:have to specify activation function");
}
activation_type = acti;
-
- return status;
}
int Layer::setOptimizer(std::shared_ptr<Optimizer> opt) {
break;
case PropertyType::activation:
if (!value.empty()) {
- status = setActivation((ActivationType)parseType(value, TOKEN_ACTI));
- throw_status(status);
+ setActivation((ActivationType)parseType(value, TOKEN_ACTI));
}
break;
case PropertyType::flatten: