template class xf::data_analytics::common::SGDFramework

#include "SGD.hpp"

Overview

Stochasitc Gradient Descent Framework.

Parameters:

Gradient gradient class which suite into this framework.
template <typename Gradient>
class SGDFramework

    // direct descendants

    template <
        typename MType,
        int WAxi,
        int WData,
        int BurstLen,
        int D,
        int DDepth,
        RAMType RAMWeight,
        RAMType RAMIntercept,
        RAMType RAMAvgWeight,
        RAMType RAMAvgIntercept
        >
    class xf::data_analytics::regression::internal::LASSORegressionSGDTrainer

    template <
        typename MType,
        int WAxi,
        int WData,
        int BurstLen,
        int D,
        int DDepth,
        RAMType RAMWeight,
        RAMType RAMIntercept,
        RAMType RAMAvgWeight,
        RAMType RAMAvgIntercept
        >
    class xf::data_analytics::regression::internal::linearLeastSquareRegressionSGDTrainer

    template <
        typename MType,
        int WAxi,
        int WData,
        int BurstLen,
        int D,
        int DDepth,
        RAMType RAMWeight,
        RAMType RAMIntercept,
        RAMType RAMAvgWeight,
        RAMType RAMAvgIntercept
        >
    class xf::data_analytics::regression::internal::ridgeRegressionSGDTrainer

// typedefs

typedef Gradient::DataType MType

// fields

static const int WAxi
static const int D
static const int Depth
ap_uint <32> offset
ap_uint <32> rows
ap_uint <32> cols
ap_uint <32> bucketSize
float fraction
bool ifJump
MType stepSize
MType tolerance
bool withIntercept
ap_uint <32> maxIter
Gradient gradProcessor

Methods

seedInitialization

void seedInitialization (ap_uint <32> seed)

Initialize RNG for sampling data.

Parameters:

seed Seed for RNG

setTrainingConfigs

void setTrainingConfigs (
    MType inputStepSize,
    MType inputTolerance,
    bool inputWithIntercept,
    ap_uint <32> inputMaxIter
    )

Set configs for SGD iteration.

Parameters:

inputStepSize steps size of SGD iteration.
inputTolerance convergence tolerance of SGD.
inputWithIntercept if SGD includes intercept or not.
inputMaxIter max iteration number of SGD.

setTrainingDataParams

void setTrainingDataParams (
    ap_uint <32> inputOffset,
    ap_uint <32> inputRows,
    ap_uint <32> inputCols,
    ap_uint <32> inputBucketSize,
    float inputFraction,
    bool inputIfJump
    )

Set configs for loading trainging data.

Parameters:

inputOffset offset of data in ddr.
inputRows number of rows of training data
inputCols number of features of training data
inputBucketSize bucketSize of jump sampling
inputFraction sample fraction
inputIfJump perform jump scaling or not.

initGradientParams

void initGradientParams (ap_uint <32> cols)

Set initial weight to zeros.

Parameters:

cols feature numbers

calcGradient

void calcGradient (ap_uint <WAxi>* ddr)

calculate gradient of current weight

Parameters:

ddr Traing Data

updateParams

bool updateParams (ap_uint <32> iterationIndex)

update weight and intercept based on gradient

Parameters:

iterationIndex iteraton index.

train

void train (ap_uint <WAxi>* ddr)

training function

Parameters:

ddr input Data