Class BagDimlp
Defined in File bagDimlp.h
Inheritance Relationships
Base Type
public Dimlp
(Class Dimlp)
Class Documentation
-
class BagDimlp : public Dimlp
Implements a bagging ensemble of Dimlp neural networks.
Public Functions
-
inline float *GetGlobalOut()
Gets the global output of the ensemble.
- Returns:
Pointer to the global output array.
-
void MakeDataSets(DataSet &masterTrain, DataSet &masterClass, int nbPat)
Creates datasets for each Dimlp network in the ensemble using bootstrap sampling.
- Parameters:
masterTrain – The master training dataset.
masterClass – The master class dataset.
nbPat – Number of patterns in the dataset.
-
void TrainAll(DataSet &test, DataSet &testTar, const std::string &genericWeightsFile, const std::string &accuracyFile, int seed = 0)
Trains all Dimlp networks in the ensemble.
- Parameters:
test – The test dataset.
testTar – The test target dataset.
genericWeightsFile – Path to the file for saving weights.
accuracyFile – Path to the file for saving accuracy.
seed – Seed for random number generation.
-
void DefNetsWithWeights(const std::string &prefix)
Initializes networks with pre-trained weights.
- Parameters:
prefix – Prefix for the weight files.
-
std::shared_ptr<VirtualHyp> MakeGlobalVirt(int nbBins, int nbIn, int multiple)
Creates a global virtual hyperplane for all networks in the ensemble.
- Parameters:
nbBins – Number of bins.
nbIn – Number of input neurons.
multiple – Multiplication factor.
- Returns:
Shared pointer to the global virtual hyperplane.
-
virtual void ForwardOneExample1(DataSet &data, int index) override
Performs forward pass using the bagged ensemble of Dimlp networks for a single example.
This method iterates over all the Dimlp networks in the ensemble (
VectDimlp
), performs a forward pass on each network, and averages their outputs to produce a final global output.- Parameters:
data – The dataset.
index – Index of the example.
-
virtual void ForwardOneExample1() override
Performs forward pass using the bagged ensemble of Dimlp networks for a single example.
This method iterates over all the Dimlp networks in the ensemble (
VectDimlp
), performs a forward pass on each network, and averages their outputs to produce a final global output.
-
void ComputeAcc(DataSet &data, DataSet &target, float *accuracy, int tW, const std::string &predFile)
Computes the accuracy of the ensemble on the given dataset.
- Parameters:
data – The dataset.
target – The target dataset.
accuracy – Pointer to store the computed accuracy.
toWrite – Flag to indicate whether to write the predictions to a file.
predFile – Path to the file for saving predictions.
-
BagDimlp(float eta, float mu, float flat, float errParam, float accuracyParam, float deltaErrParam, int discrLevels, int showErrParam, int nbEpochsParam, int nbLayers, std::vector<int> nbNeurons, int nbDimlpNets, const std::string &weightFile, int seed = 0)
Constructs a BagDimlp object.
- Parameters:
eta – Learning rate.
mu – Momentum.
flat – Flat spot elimination parameter.
errParam – Error threshold parameter.
accuracyParam – Accuracy threshold parameter.
deltaErrParam – Delta error threshold parameter.
discrLevels – Number of discretization levels.
showErrParam – Frequency of error display.
nbEpochsParam – Number of training epochs.
nbLayers – Number of layers.
nbNeurons – Vector containing the number of neurons in each layer.
nbDimlpNets – Number of Dimlp networks in the ensemble.
weightFile – Path to the file for saving weights.
seed – Seed for random number generation.
-
BagDimlp(int discrLevels, int nbLayers, std::vector<int> nbNeurons, int nbDimlpNets, const std::string &weightFile, int seed = 0)
Constructs a BagDimlp object with specified discretization levels, layers, and neurons.
- Parameters:
discrLevels – Number of discretization levels.
nbLayers – Number of layers.
nbNeurons – Vector containing the number of neurons in each layer.
nbDimlpNets – Number of Dimlp networks in the ensemble.
weightFile – Path to the file for saving weights.
seed – Seed for random number generation.
-
virtual void ForwardOneExample1(float *ex)
Forwards one example through the network.
- Parameters:
ex – The example to forward.
-
inline float *GetGlobalOut()