NumRec Fixes

This commit is contained in:
IlyaShurupov 2023-10-25 20:41:48 +03:00
parent 0542b7ba2e
commit 826713c212
5 changed files with 181 additions and 148 deletions

View 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;
};
};