- moved method of layer interaction from Layer to Stack

git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@817 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2022-01-17 08:33:30 +00:00
parent c2f5083fc3
commit a372f1a30d
9 changed files with 381 additions and 117 deletions
+79
View File
@@ -0,0 +1,79 @@
/*
* 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"
class LayerConstructor
{
public:
LayerConstructor() {}
virtual ~LayerConstructor() {}
virtual Layer* onConstruct(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
};
const char *stackTypeStrings[NUM_STACKTYPES] = {"None", "Deep", "Rnn"};
AStack(const std::string &dir, StackType type, const std::string &name);
AStack(const AStack& orig);
virtual ~AStack();
void setName(const std::string &name);
size_t numLayers();
void addLayer(Layer *pLayer);
void delLayer(Layer *pLayer);
Layer* getLayer(size_t layerId) const;
bool load(LayerConstructor *pLayerConstructor=nullptr);
bool save();
void weightsInit(double stddev);
bool loadWeights();
bool saveWeights();
arma::mat upPass(size_t layerId, arma::mat const &v);
arma::mat downPass(size_t layerId, arma::mat const &h);
arma::mat upDownPass(size_t layerId, arma::mat const &v);
protected:
StackType m_type;
std::string m_name;
Layer *m_pLayers;
std::string m_dir;
};
#endif /* ASTACK_HPP */