Make minor changes suggested by ShikharJ.

This commit is contained in:
walragatver
2019-10-12 18:51:48 +05:30
parent 23463aba54
commit f3d6e7705e
4 changed files with 13 additions and 40 deletions
+4 -7
View File
@@ -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.
+5 -15
View File
@@ -48,7 +48,6 @@ GAN<Model, InitializationRuleType, Noise, PolicyType>::GAN(
noiseDim(noiseDim),
numFunctions(0),
batchSize(batchSize),
counter(0),
currentBatch(0),
generatorUpdateStep(generatorUpdateStep),
preTrainSize(preTrainSize),
@@ -88,7 +87,6 @@ GAN<Model, InitializationRuleType, Noise, PolicyType>::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<Model, InitializationRuleType, Noise, PolicyType>::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<Model, InitializationRuleType, Noise, PolicyType>::ResetData(
arma::mat trainData)
{
counter = 0;
currentBatch = 0;
numFunctions = trainData.n_cols;
@@ -166,7 +162,7 @@ void GAN<Model, InitializationRuleType, Noise, PolicyType>::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<Model, InitializationRuleType, Noise, PolicyType>::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<Model, InitializationRuleType, Noise, PolicyType>::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<Model, InitializationRuleType, Noise, PolicyType>::
Predict(arma::mat input, arma::mat& output)
{
if (parameter.is_empty())
if ((parameter.is_empty()))
Reset();
if (!deterministic)
+2 -9
View File
@@ -34,7 +34,7 @@ GAN<Model, InitializationRuleType, Noise, PolicyType>::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--;
+2 -9
View File
@@ -35,7 +35,7 @@ GAN<Model, InitializationRuleType, Noise, PolicyType>::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--;