Overload Evaluate() function.

This commit is contained in:
akhandait
2018-08-07 18:45:16 +05:30
parent f4180deb9d
commit f599f7cf8b
2 changed files with 36 additions and 0 deletions
+9
View File
@@ -134,6 +134,15 @@ class FFN
*/
void Predict(arma::mat predictors, arma::mat& results);
/**
* Evaluate the feedforward network with the given ppredictors and responses.
* This functions is usually used to monitor progress while training.
*
* @param predictors Input variables.
* @param responses Target outputs for input variables.
*/
double Evaluate(arma::mat predictors, arma::mat responses);
/**
* Evaluate the feedforward network with the given parameters. This function
* is usually called by the optimizer to train the model.
+27
View File
@@ -202,6 +202,33 @@ void FFN<OutputLayerType, InitializationRuleType, CustomLayers...>::Predict(
results.col(i) = resultsTemp.col(0);
}
}
template<typename OutputLayerType, typename InitializationRuleType,
typename... CustomLayers>
double FFN<OutputLayerType, InitializationRuleType, CustomLayers...>::Evaluate(
arma::mat predictors, arma::mat responses)
{
if (parameter.is_empty())
ResetParameters();
if (!deterministic)
{
deterministic = true;
ResetDeterministic();
}
Forward(std::move(predictors));
double res = outputLayer.Forward(
std::move(boost::apply_visitor(outputParameterVisitor, network.back())),
std::move(responses));
for (size_t i = 0; i < network.size(); ++i)
{
res += boost::apply_visitor(lossVisitor, network[i]);
}
return res;
}
template<typename OutputLayerType, typename InitializationRuleType,
typename... CustomLayers>