further development
git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@17 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* HiddenLayer.hpp
|
||||
*
|
||||
* Created on: 21.09.2014
|
||||
* Author: jens
|
||||
*/
|
||||
|
||||
#ifndef HIDDENLAYER_HPP_
|
||||
#define HIDDENLAYER_HPP_
|
||||
|
||||
#include "Layer.hpp"
|
||||
#include <cmath>
|
||||
|
||||
class HiddenLayer : public Layer
|
||||
{
|
||||
public:
|
||||
HiddenLayer(uint32_t numUnits = 0, const double *pStatesInit = nullptr)
|
||||
: Layer(numUnits, pStatesInit)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~HiddenLayer()
|
||||
{
|
||||
}
|
||||
|
||||
double getEnergy(const Weights &weights)
|
||||
{
|
||||
uint32_t i;
|
||||
double energy = 0;
|
||||
|
||||
for (i=0; i < getNumUnits(); i++)
|
||||
{
|
||||
energy -= weights.getBiasHidden()[i] * getStates()[i];
|
||||
}
|
||||
return energy;
|
||||
}
|
||||
|
||||
private:
|
||||
double accum(const Layer &layer, const Weights &weights, uint32_t index) const
|
||||
{
|
||||
uint32_t i;
|
||||
double sum = weights.getBiasVisible()[index];
|
||||
const double *pStates = layer.getStates();
|
||||
|
||||
for (i=0; i < layer.getNumUnits(); i++)
|
||||
{
|
||||
sum += pStates[i] * weights.getWeights()[index][i];
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* HIDDENLAYER_HPP_ */
|
||||
Reference in New Issue
Block a user