diff --git a/src/mlpack/methods/ann/gan/gan.hpp b/src/mlpack/methods/ann/gan/gan.hpp index db217d9c47..19cc6666bb 100644 --- a/src/mlpack/methods/ann/gan/gan.hpp +++ b/src/mlpack/methods/ann/gan/gan.hpp @@ -68,9 +68,9 @@ class GAN * * @param generator Generator network. * @param discriminator Discriminator network. - * @param initializeRule Intialization to use for intializing parameters. + * @param initializeRule Initialization to use for initializing parameters. * @param noiseFunction Function to be used for generating noise. - * @param noiseDim Dimension of noise to be created. + * @param noiseDim Dimension of noise vector to be created. * @param batchSize Batch size to be used for training. * @param generatorUpdateStep Number of steps to train Discriminator * before updating Generator. @@ -98,9 +98,8 @@ class GAN GAN(GAN&&); /** - * Intialize the generator, discriminator and weights of the model for - * training. - * This function won't actually trigger training process. + * Initialize the generator, discriminator and weights of the model for + * training. This function won't actually trigger training process. * * @param trainData The data points of real distribution. */ @@ -349,8 +348,6 @@ class GAN size_t numFunctions; //! Locally stored batch size parameter. size_t batchSize; - //! Locally stored number of iterations that have been completed. - size_t counter; //! Locally stored batch number which is being processed. size_t currentBatch; //! Locally stored number of training step before Generator is trained. diff --git a/src/mlpack/methods/ann/gan/gan_impl.hpp b/src/mlpack/methods/ann/gan/gan_impl.hpp index d5714da93a..0c12677a73 100644 --- a/src/mlpack/methods/ann/gan/gan_impl.hpp +++ b/src/mlpack/methods/ann/gan/gan_impl.hpp @@ -48,7 +48,6 @@ GAN::GAN( noiseDim(noiseDim), numFunctions(0), batchSize(batchSize), - counter(0), currentBatch(0), generatorUpdateStep(generatorUpdateStep), preTrainSize(preTrainSize), @@ -88,7 +87,6 @@ GAN::GAN( clippingParameter(network.clippingParameter), lambda(network.lambda), reset(network.reset), - counter(network.counter), currentBatch(network.currentBatch), parameter(network.parameter), numFunctions(network.numFunctions), @@ -122,7 +120,6 @@ GAN::GAN( clippingParameter(network.clippingParameter), lambda(network.lambda), reset(network.reset), - counter(network.counter), currentBatch(network.currentBatch), parameter(std::move(network.parameter)), numFunctions(network.numFunctions), @@ -143,7 +140,6 @@ template< void GAN::ResetData( arma::mat trainData) { - counter = 0; currentBatch = 0; numFunctions = trainData.n_cols; @@ -166,7 +162,7 @@ void GAN::ResetData( this->generator.predictors.set_size(noiseDim, batchSize); this->generator.responses.set_size(predictors.n_rows, batchSize); - if (!reset) + if ((!reset)) Reset(); } @@ -238,7 +234,7 @@ GAN::Evaluate( const size_t i, const size_t /* batchSize */) { - if (parameter.is_empty()) + if ((parameter.is_empty())) Reset(); if (!deterministic) @@ -293,7 +289,7 @@ EvaluateWithGradient(const arma::mat& /* parameters */, GradType& gradient, const size_t /* batchSize */) { - if (parameter.is_empty()) + if ((parameter.is_empty())) Reset(); if (gradient.is_empty()) @@ -364,14 +360,8 @@ EvaluateWithGradient(const arma::mat& /* parameters */, gradientGenerator *= multiplier; } - counter++; currentBatch++; - // Revert the counter to zero, if the total dataset get's covered. - if (counter * batchSize >= numFunctions) - { - counter = 0; - } if (preTrainSize > 0) { @@ -421,7 +411,7 @@ template< void GAN::Forward( arma::mat&& input) { - if (parameter.is_empty()) + if ((parameter.is_empty())) Reset(); generator.Forward(std::move(input)); @@ -440,7 +430,7 @@ template< void GAN:: Predict(arma::mat input, arma::mat& output) { - if (parameter.is_empty()) + if ((parameter.is_empty())) Reset(); if (!deterministic) diff --git a/src/mlpack/methods/ann/gan/wgan_impl.hpp b/src/mlpack/methods/ann/gan/wgan_impl.hpp index 92a6c55a8e..aa88759fe1 100644 --- a/src/mlpack/methods/ann/gan/wgan_impl.hpp +++ b/src/mlpack/methods/ann/gan/wgan_impl.hpp @@ -34,7 +34,7 @@ GAN::Evaluate( const size_t i, const size_t /* batchSize */) { - if (parameter.is_empty()) + if ((parameter.is_empty())) Reset(); if (!deterministic) @@ -88,7 +88,7 @@ EvaluateWithGradient(const arma::mat& /* parameters */, GradType& gradient, const size_t /* batchSize */) { - if (parameter.is_empty()) + if ((parameter.is_empty())) Reset(); if (gradient.is_empty()) @@ -161,15 +161,8 @@ EvaluateWithGradient(const arma::mat& /* parameters */, gradientGenerator *= multiplier; } - counter++; currentBatch++; - // Revert the counter to zero, if the total dataset get's covered. - if (counter * batchSize >= numFunctions) - { - counter = 0; - } - if (preTrainSize > 0) { preTrainSize--; diff --git a/src/mlpack/methods/ann/gan/wgangp_impl.hpp b/src/mlpack/methods/ann/gan/wgangp_impl.hpp index 88bf257255..bb2743ed73 100644 --- a/src/mlpack/methods/ann/gan/wgangp_impl.hpp +++ b/src/mlpack/methods/ann/gan/wgangp_impl.hpp @@ -35,7 +35,7 @@ GAN::Evaluate( const size_t i, const size_t /* batchSize */) { - if (parameter.is_empty()) + if ((parameter.is_empty())) Reset(); if (!deterministic) @@ -102,7 +102,7 @@ EvaluateWithGradient(const arma::mat& /* parameters */, GradType& gradient, const size_t /* batchSize */) { - if (parameter.is_empty()) + if ((parameter.is_empty())) Reset(); if (gradient.is_empty()) @@ -185,15 +185,8 @@ EvaluateWithGradient(const arma::mat& /* parameters */, gradientGenerator *= multiplier; } - counter++; currentBatch++; - // Revert the counter to zero, if the total dataset get's covered. - if (counter * batchSize >= numFunctions) - { - counter = 0; - } - if (preTrainSize > 0) { preTrainSize--;