Overload Forward() function.
This commit is contained in:
@@ -284,6 +284,22 @@ class FFN
|
||||
*/
|
||||
void Forward(arma::mat inputs, arma::mat& results);
|
||||
|
||||
/**
|
||||
* Perform a partial forward pass of the data.
|
||||
*
|
||||
* This function is meant for the cases when users require a forward pass only
|
||||
* through certain layers and not the entire network.
|
||||
*
|
||||
* @param inputs The input data for the specified first layer.
|
||||
* @param results The predicted results from the specified last layer.
|
||||
* @param begin The index of the first layer.
|
||||
* @param end The index of the last layer.
|
||||
*/
|
||||
void Forward(arma::mat inputs,
|
||||
arma::mat& results,
|
||||
const size_t begin,
|
||||
const size_t end);
|
||||
|
||||
/**
|
||||
* Perform the backward pass of the data in real batch mode.
|
||||
*
|
||||
|
||||
@@ -124,6 +124,26 @@ void FFN<OutputLayerType, InitializationRuleType, CustomLayers...>::Forward(
|
||||
results = boost::apply_visitor(outputParameterVisitor, network.back());
|
||||
}
|
||||
|
||||
template<typename OutputLayerType, typename InitializationRuleType,
|
||||
typename... CustomLayers>
|
||||
void FFN<OutputLayerType, InitializationRuleType, CustomLayers...>::Forward(
|
||||
arma::mat inputs, arma::mat& results, const size_t begin, const size_t end)
|
||||
{
|
||||
boost::apply_visitor(ForwardVisitor(std::move(inputs), std::move(
|
||||
boost::apply_visitor(outputParameterVisitor, network[begin]))),
|
||||
network[begin]);
|
||||
|
||||
for (size_t i = 1; i < end - begin + 1; ++i)
|
||||
{
|
||||
boost::apply_visitor(ForwardVisitor(std::move(boost::apply_visitor(
|
||||
outputParameterVisitor, network[begin + i - 1])), std::move(
|
||||
boost::apply_visitor(outputParameterVisitor, network[begin + i]))),
|
||||
network[begin + i]);
|
||||
}
|
||||
|
||||
results = boost::apply_visitor(outputParameterVisitor, network[end]);
|
||||
}
|
||||
|
||||
template<typename OutputLayerType, typename InitializationRuleType,
|
||||
typename... CustomLayers>
|
||||
double FFN<OutputLayerType, InitializationRuleType, CustomLayers...>::Backward(
|
||||
|
||||
Reference in New Issue
Block a user