Files
Rbm/source/AStack.hpp
T
jens 51e6eef12e - refactored
git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@824 b431acfa-c32f-4a4a-93f1-934dc6c82436
2022-01-17 20:22:10 +00:00

83 lines
1.6 KiB
C++

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: AStack.hpp
* Author: jens
*
* Created on 16. Januar 2022, 13:55
*/
#ifndef ASTACK_HPP
#define ASTACK_HPP
#include <string>
#include <vector>
#include <armadillo>
#include <jsoncpp/json/json.h>
#include "Layer.hpp"
#include <forward_list>
class AStack;
class LayerConstructor
{
public:
LayerConstructor() {}
virtual ~LayerConstructor() {}
virtual Layer* onConstruct(AStack *pStack, const std::string &name, size_t id, size_t numVisibleX, size_t numVisibleY, size_t numHidden, size_t numContext)
{
return nullptr;
}
};
class AStack
{
public:
enum StackType
{
None,
Deep,
Rnn,
NUM_STACKTYPES
};
static const char *stackTypeStrings[NUM_STACKTYPES];
AStack(StackType type, const std::string &name);
AStack(const AStack& orig) = delete;
virtual ~AStack();
StackType type();
void setName(const std::string &name);
size_t numLayers();
void addLayer(Layer *pLayer);
void delLayer(Layer *pLayer);
Layer* getLayer(size_t layerId) const;
bool save(const std::string &dir);
void weightsInit(double stddev);
bool loadWeights(const std::string &dir);
bool saveWeights(const std::string &dir);
virtual void train(size_t layerId, const arma::mat& batch, Rbm::IListener* pListener) = 0;
virtual void train(const arma::mat& batch, Rbm::IListener* pListener) = 0;
arma::mat trainingBatchFrom(size_t layerId, const arma::mat& batch);
protected:
StackType m_type;
std::string m_name;
Layer *m_pLayers;
private:
};
#endif /* ASTACK_HPP */