mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-11-14 14:07:18 +01:00
113 lines
2.6 KiB
C++
113 lines
2.6 KiB
C++
|
|
#ifndef MLPP_HIDDEN_LAYER_H
|
|
#define MLPP_HIDDEN_LAYER_H
|
|
|
|
//
|
|
// HiddenLayer.hpp
|
|
//
|
|
// Created by Marc Melikyan on 11/4/20.
|
|
//
|
|
|
|
#include "core/math/math_defs.h"
|
|
#include "core/string/ustring.h"
|
|
|
|
#include "core/object/reference.h"
|
|
|
|
#include "../activation/activation.h"
|
|
#include "../regularization/reg.h"
|
|
#include "../utilities/utilities.h"
|
|
|
|
#include "../lin_alg/mlpp_matrix.h"
|
|
#include "../lin_alg/mlpp_vector.h"
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class MLPPHiddenLayer : public Reference {
|
|
GDCLASS(MLPPHiddenLayer, Reference);
|
|
|
|
public:
|
|
int get_n_hidden() const;
|
|
void set_n_hidden(const int val);
|
|
|
|
MLPPActivation::ActivationFunction get_activation() const;
|
|
void set_activation(const MLPPActivation::ActivationFunction val);
|
|
|
|
Ref<MLPPMatrix> get_input();
|
|
void set_input(const Ref<MLPPMatrix> &val);
|
|
|
|
Ref<MLPPMatrix> get_weights();
|
|
void set_weights(const Ref<MLPPMatrix> &val);
|
|
|
|
Ref<MLPPVector> get_bias();
|
|
void set_bias(const Ref<MLPPVector> &val);
|
|
|
|
Ref<MLPPMatrix> get_z();
|
|
void set_z(const Ref<MLPPMatrix> &val);
|
|
|
|
Ref<MLPPMatrix> get_a();
|
|
void set_a(const Ref<MLPPMatrix> &val);
|
|
|
|
Ref<MLPPVector> get_z_test();
|
|
void set_z_test(const Ref<MLPPVector> &val);
|
|
|
|
Ref<MLPPVector> get_a_test();
|
|
void set_a_test(const Ref<MLPPVector> &val);
|
|
|
|
Ref<MLPPMatrix> get_delta();
|
|
void set_delta(const Ref<MLPPMatrix> &val);
|
|
|
|
MLPPReg::RegularizationType get_reg() const;
|
|
void set_reg(const MLPPReg::RegularizationType val);
|
|
|
|
real_t get_lambda() const;
|
|
void set_lambda(const real_t val);
|
|
|
|
real_t get_alpha() const;
|
|
void set_alpha(const real_t val);
|
|
|
|
MLPPUtilities::WeightDistributionType get_weight_init() const;
|
|
void set_weight_init(const MLPPUtilities::WeightDistributionType val);
|
|
|
|
bool is_initialized();
|
|
void initialize();
|
|
|
|
void forward_pass();
|
|
void test(const Ref<MLPPVector> &x);
|
|
|
|
MLPPHiddenLayer(int p_n_hidden, MLPPActivation::ActivationFunction p_activation, Ref<MLPPMatrix> p_input, MLPPUtilities::WeightDistributionType p_weight_init, MLPPReg::RegularizationType p_reg, real_t p_lambda, real_t p_alpha);
|
|
|
|
MLPPHiddenLayer();
|
|
~MLPPHiddenLayer();
|
|
|
|
protected:
|
|
static void _bind_methods();
|
|
|
|
int n_hidden;
|
|
MLPPActivation::ActivationFunction activation;
|
|
|
|
Ref<MLPPMatrix> input;
|
|
|
|
Ref<MLPPMatrix> weights;
|
|
Ref<MLPPVector> bias;
|
|
|
|
Ref<MLPPMatrix> z;
|
|
Ref<MLPPMatrix> a;
|
|
|
|
Ref<MLPPVector> z_test;
|
|
Ref<MLPPVector> a_test;
|
|
|
|
Ref<MLPPMatrix> delta;
|
|
|
|
// Regularization Params
|
|
MLPPReg::RegularizationType reg;
|
|
real_t lambda; /* Regularization Parameter */
|
|
real_t alpha; /* This is the controlling param for Elastic Net*/
|
|
|
|
MLPPUtilities::WeightDistributionType weight_init;
|
|
|
|
bool _initialized;
|
|
};
|
|
|
|
#endif /* HiddenLayer_hpp */ |