Skip to content

Instantly share code, notes, and snippets.

View kris-singh's full-sized avatar
🎯
Focusing

Kris Singh kris-singh

🎯
Focusing
View GitHub Profile
template<typename DecomposableFunctionType, typename DecayType = SomeValue>
class SGD
{
...
...
...
...
private:
...
}
template<typename DecomposableFunctionType>
class SGD
{
...
...
double Optimize(arma::mat& iterate);
template<typename Policy>
double Optimize(arma::mat& iterate)
...
...
/**
* @file fanin_visitor_impl.hpp
* @author KrishnaKant Singh
*
* Implementation of the fain layer abstraction.
*
* 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
* 3-clause BSD license along with mlpack. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
/**
* @file ffn.hpp
* @author Marcus Edel
*
* Definition of the FFN class, which implements feed forward neural networks.
*
* 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
* 3-clause BSD license along with mlpack. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
/**
* @file fanin_visitor_impl.hpp
* @author Marcus Edel
* @author Kris Singh
*
* Implementation of the fain layer abstraction.
*
* 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
* 3-clause BSD license along with mlpack. If not, see
#include <cmath>
#include <time.h>
#include <stdlib.h>
#include <mlpack/core.hpp>
#include <mlpack/methods/ann/ffn.hpp>
#include <mlpack/methods/ann/layer/layer.hpp>
#include <mlpack/methods/ann/layer/leaky_relu.hpp>
#include <mlpack/methods/ann/visitor/reset_visitor.hpp>
#include <mlpack/methods/ann/visitor/backward_visitor.hpp>
#include <cmath>
#include <time.h>
#include <stdlib.h>
#include <mlpack/core.hpp>
#include <mlpack/methods/ann/ffn.hpp>
#include <mlpack/methods/ann/layer/layer.hpp>
#include <mlpack/methods/ann/layer/leaky_relu.hpp>
#include <mlpack/methods/ann/visitor/reset_visitor.hpp>
#include <mlpack/methods/ann/visitor/backward_visitor.hpp>
Nestrov_update_policy.hpp
.....
arma::mat TempUpdate(arma::mat& iterate,
const double momentum,
arma::mat& velocity)
{
return iterate + momentum*velocity;
}
......
sgd.hpp
FFN<NegativeLogLikelihood<> > model;
model.Add<Linear<> >(trainData.n_rows, hiddenLayerSize);
model.Add<SigmoidLayer<> >();
model.Add<Linear<> >(hiddenLayerSize, outputSize);
model.Add<LogSoftMax<> >();
MomentumUpdate momentumUpdate(0.7);
NoDecay noDecay;
SGD<decltype(model), MomentumUpdate, NoDecay> opt(model, 0.01, maxEpochs * trainData.n_cols,
1e-5 , true, momentumUpdate, noDecay);
template <
typename InputDataType = arma::mat,
typename OutputDataType = arma::mat
>
class AdverserialLoss
{
public:
/**
* Create the AdverserialLoss object
*/