NumRec Fixes
This commit is contained in:
parent
90ce453b60
commit
4804e51ad7
5 changed files with 181 additions and 148 deletions
52
DataAnalysis/public/FCNN.hpp
Normal file
52
DataAnalysis/public/FCNN.hpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#pragma once
|
||||
|
||||
#include "Buffer.hpp"
|
||||
#include "DataAnalysisCommon.hpp"
|
||||
|
||||
namespace tp {
|
||||
// Fully connected neural network
|
||||
class FCNN {
|
||||
|
||||
struct Layer {
|
||||
|
||||
struct Neuron {
|
||||
struct Parameter {
|
||||
Parameter() = default;
|
||||
|
||||
Parameter(halnf in) :
|
||||
val(in) {}
|
||||
|
||||
halnf val = 0;
|
||||
halnf grad = 0;
|
||||
};
|
||||
|
||||
Parameter bias;
|
||||
Buffer<Parameter> weights;
|
||||
|
||||
halnf activationValue = 0;
|
||||
halnf activationValueLinear = 0;
|
||||
|
||||
halnf cache;
|
||||
};
|
||||
|
||||
Buffer<Neuron> neurons;
|
||||
};
|
||||
|
||||
public:
|
||||
FCNN() = default;
|
||||
explicit FCNN(const Buffer<halni>& description);
|
||||
|
||||
void initializeRandom(const Buffer<halni>& description);
|
||||
void evaluate(const Buffer<halnf>& input, Buffer<halnf>& output);
|
||||
|
||||
halnf calcCost(const Buffer<halnf>& output);
|
||||
|
||||
void clearGrad();
|
||||
void calcGrad(const Buffer<halnf>& output);
|
||||
void applyGrad(halnf step);
|
||||
|
||||
public:
|
||||
Buffer<Layer> mLayers;
|
||||
halni mAvgCount = 0;
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue