Overload Evaluate() function.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user