Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikdutt18 committed Aug 12, 2020
1 parent 68780d0 commit acc4eb0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 30 deletions.
2 changes: 0 additions & 2 deletions dataloader/preprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ class PreProcessor
{
// Convert each element to uint8 first and then divide by 255.
for (size_t i = 0; i < trainFeatures.n_elem; i++)
{
trainFeatures(i) = ((uint8_t)(trainFeatures(i)) / 255.0);
}
}
}
};
Expand Down
6 changes: 2 additions & 4 deletions ensmallen_utils/periodic_save.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class PeriodicSave
* @param network Network type which will be saved periodically.
* @param filePath Base path / folder where weights will be saved.
* @param modelPrefix Weights will be stored as
* modelPrefix_epoch_loss.bin.
* modelPrefix_epoch_loss.bin.
* @param period Period after which the model will be saved.
* @param silent Boolean to determine whether or not to print saving
* of model.
* of model.
* @param output Outputstream where output will be directed.
*/
PeriodicSave(AnnType& network,
Expand Down Expand Up @@ -70,9 +70,7 @@ class PeriodicSave
objectiveString;
mlpack::data::Save(filePath + modelName + ".bin", modelPrefix, network);
if (!silent)
{
output << "Model saved as " << modelName << std::endl;
}
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions ensmallen_utils/print_metric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace ens {
*
* @tparam ANNType Type of model which will be used for evaluating metric.
* @tparam MetricType Metric class which must have static `Evaluate` function
* that will be called at the end of the epoch.
* that will be called at the end of the epoch.
* @tparam InputType Arma type of dataset features.
* @tparam OutputType Arma type of dataset labels.
*/
Expand All @@ -42,7 +42,7 @@ class PrintMetric
* @param responses Ground truth label for the mdoel.
* @param metricName Metric name which will be printed after each epoch.
* @param trainData Boolean to determine whether dataset corresponds to
* training data or validation data.
* training data or validation data.
* @param output Outputstream where output will be directed.
*/
PrintMetric(AnnType &network,
Expand Down
29 changes: 11 additions & 18 deletions models/darknet/darknet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file darknet.hpp
* @author Kartik Dutt
*
* Definition of Darknet models.
* Definition of DarkNet models.
*
* For more information, kindly refer to the following paper.
*
Expand Down Expand Up @@ -50,7 +50,7 @@ namespace mlpack {
namespace ann /** Artificial Neural Network. */{

/**
* Definition of a Darknet CNN.
* Definition of a DarkNet CNN.
*
* @tparam OutputLayerType The output layer type used to evaluate the network.
* @tparam InitializationRuleType Rule used to initialize the weight matrix.
Expand All @@ -74,8 +74,8 @@ class DarkNet
* @param inputWidth Width of the input image.
* @param inputHeight Height of the input image.
* @param numClasses Optional number of classes to classify images into,
* only to be specified if includeTop is true.
* @param weights One of 'none', 'cifar10'(pre-training on CIFAR10) or path to weights.
* only to be specified if includeTop is true.
* @param weights One of 'none', 'imagenet'(pre-training on ImageNet) or path to weights.
* @param includeTop Must be set to true if weights are set.
*/
DarkNet(const size_t inputChannel,
Expand All @@ -89,12 +89,11 @@ class DarkNet
* DarkNet constructor intializes input shape and number of classes.
*
* @param inputShape A three-valued tuple indicating input shape.
* First value is number of Channels (Channels-First).
* Second value is input height.
* Third value is input width..
* First value is number of channels (channels-first).
* Second value is input height. Third value is input width.
* @param numClasses Optional number of classes to classify images into,
* only to be specified if includeTop is true.
* @param weights One of 'none', 'cifar10'(pre-training on CIFAR10) or path to weights.
* only to be specified if includeTop is true.
* @param weights One of 'none', 'imagenet'(pre-training on ImageNet) or path to weights.
*/
DarkNet(const std::tuple<size_t, size_t, size_t> inputShape,
const size_t numClasses = 1000,
Expand All @@ -115,7 +114,7 @@ class DarkNet
* Adds Convolution Block.
*
* @tparam SequentialType Layer type in which convolution block will
* be added.
* be added.
*
* @param inSize Number of input maps.
* @param outSize Number of output maps.
Expand All @@ -126,7 +125,7 @@ class DarkNet
* @param padW Padding width of the input.
* @param padH Padding height of the input.
* @param batchNorm Boolean to determine whether a batch normalization
* layer is added.
* layer is added.
* @param negativeSlope Negative slope hyper-parameter for LeakyReLU.
* @param baseLayer Layer in which Convolution block will be added, if
* NULL added to darkNet FFN.
Expand Down Expand Up @@ -160,28 +159,22 @@ class DarkNet
", " << outSize << ")" << std::endl;

if (batchNorm)
{
bottleNeck->Add(new BatchNorm<>(outSize, 1e-5, false));
}

bottleNeck->Add(new LeakyReLU<>(negativeSlope));

if (baseLayer != NULL)
{
baseLayer->Add(bottleNeck);
}
else
{
darkNet.Add(bottleNeck);
}
}

/**
* Adds Pooling Block.
*
* @param factor The factor by which input dimensions will be divided.
* @param type One of "max" or "mean". Determines whether add mean pooling
* layer or max pooling layer.
* layer or max pooling layer.
*/
void PoolingBlock(const size_t factor = 2,
const std::string type = "max")
Expand Down
6 changes: 2 additions & 4 deletions models/darknet/darknet_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file darknet_impl.hpp
* @author Kartik Dutt
*
* Implementation of LeNet using mlpack.
* Implementation of DarkNet using mlpack.
*
* mlpack is free software; you may redistribute it and/or modify it under the
* terms of the 3-clause BSD license. You should have received a copy of the
Expand Down Expand Up @@ -113,7 +113,7 @@ DarkNet<OutputLayerType, InitializationRuleType, DarkNetVersion>::DarkNet(
if (includeTop)
{
darkNet.Add(new Convolution<>(1024, numClasses, 1, 1,
1, 1, 0, 0, inputWidth, inputHeight));
1, 1, 0, 0, inputWidth, inputHeight));
darkNet.Add(new AdaptiveMeanPooling<>(1, 1));
darkNet.Add(new LogSoftMax<>());
}
Expand All @@ -134,9 +134,7 @@ DarkNet<OutputLayerType, InitializationRuleType, DarkNetVersion>::DarkNet(
for (size_t blockCount : residualBlockConfig)
{
for (size_t i = 0; i < blockCount; i++)
{
DarkNet53ResidualBlock(curChannels);
}

if (blockCount != 4)
{
Expand Down

0 comments on commit acc4eb0

Please sign in to comment.