Distinguish between testing and training when optimizing the network model. This is useful for models that act differently when in testing or training mode.
This commit is contained in:
@@ -182,7 +182,7 @@ class CNN
|
||||
*/
|
||||
double Evaluate(const arma::mat& parameters,
|
||||
const size_t i,
|
||||
const bool deterministic = false);
|
||||
const bool deterministic = true);
|
||||
|
||||
/**
|
||||
* Evaluate the gradient of the convolutional neural network with the given
|
||||
|
||||
@@ -245,9 +245,11 @@ template<typename LayerTypes,
|
||||
void CNN<
|
||||
LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction
|
||||
>::Gradient(const arma::mat& /* unused */,
|
||||
const size_t /* unused */,
|
||||
const size_t i,
|
||||
arma::mat& gradient)
|
||||
{
|
||||
Evaluate(parameter, i, false);
|
||||
|
||||
NetworkGradients(gradient, network);
|
||||
|
||||
Backward<>(error, network);
|
||||
|
||||
@@ -183,7 +183,7 @@ class FFN
|
||||
*/
|
||||
double Evaluate(const arma::mat& parameters,
|
||||
const size_t i,
|
||||
const bool deterministic = false);
|
||||
const bool deterministic = true);
|
||||
|
||||
/**
|
||||
* Evaluate the gradient of the feedforward network with the given parameters,
|
||||
|
||||
@@ -249,9 +249,11 @@ template<typename LayerTypes,
|
||||
void FFN<
|
||||
LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction
|
||||
>::Gradient(const arma::mat& /* unused */,
|
||||
const size_t /* unused */,
|
||||
const size_t i,
|
||||
arma::mat& gradient)
|
||||
{
|
||||
Evaluate(parameter, i, false);
|
||||
|
||||
NetworkGradients(gradient, network);
|
||||
|
||||
Backward<>(error, network);
|
||||
|
||||
@@ -185,7 +185,7 @@ class RNN
|
||||
*/
|
||||
double Evaluate(const arma::mat& parameters,
|
||||
const size_t i,
|
||||
const bool deterministic = false);
|
||||
const bool deterministic = true);
|
||||
|
||||
/**
|
||||
* Evaluate the gradient of the recurrent neural network with the given
|
||||
|
||||
@@ -281,6 +281,8 @@ LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction
|
||||
const size_t i,
|
||||
arma::mat& gradient)
|
||||
{
|
||||
Evaluate(parameter, i, false);
|
||||
|
||||
gradient.zeros();
|
||||
arma::mat currentGradient = arma::mat(gradient.n_rows, gradient.n_cols);
|
||||
NetworkGradients(currentGradient, network);
|
||||
|
||||
Reference in New Issue
Block a user