BackProp Initial

This commit is contained in:
IlyaShurupov 2023-10-23 13:38:00 +03:00
parent 744c01c5d0
commit efbb09f8ba
6 changed files with 166 additions and 4 deletions

View file

@ -5,23 +5,42 @@
namespace tp {
class FullyConnectedNN {
struct Layer {
struct Neuron {
halnf mBias = 0;
Buffer<halnf> mWeights;
halnf mActivationValue = 0;
halnf mActivationValueLinear = 0;
};
Buffer<Neuron> mNeurons;
};
struct LayerCache {
struct NeuronCache {
halnf mBiasGrad = 0;
Buffer<halnf> mWeightsGrad;
};
halnf mCache = 0;
Buffer<NeuronCache> mNeurons;
};
public:
FullyConnectedNN() = default;
void initializeRandom(Buffer<halni> description);
void evaluate(const Buffer<halnf>& input, Buffer<halnf>& output);
void clearGrad();
halnf calcCost(const Buffer<halnf>& output);
void calcGrad(const Buffer<halnf>& output);
void applyGrad();
private:
Buffer<Layer> mLayers;
Buffer<LayerCache> mLayersCache;
halni mAvgCount = 0;
};
};