51 void AddLayer(
int inChannels,
int outChannels,
52 int inHeight,
int inWidth,
53 int kernelH,
int kernelW,
54 int strideH = 1,
int strideW = 1,
55 int padH = 0,
int padW = 0,
56 float lr = 1e-6f,
float ir = 0.1f,
float lmbda = 1e-2f,
78 void Clamp(const std::vector<
float> &input) noexcept;
94 const auto &
GetLayers() const noexcept {
return layers; }
100 float TrainStep(
const std::vector<float> &x,
const std::vector<float> &y,
int inferenceSteps);
104 std::vector<float>
Predict(
const std::vector<float> &x,
int inferenceSteps);
124#if defined(DEEPITY_USE_CUDA)
125 std::unique_ptr<DeviceMemoryArena> gpuArena;
A 64-byte-aligned bump-pointer allocator over a single device buffer, mirroring this codebase's host-...
A 64-byte-aligned bump-pointer allocator over a single heap-allocated block, used to pack every layer...
ConvPCLayer with precision removed, AdamW/Adam support, now routed through IComputeBackend for GPU po...
Device-agnostic compute backend interface: every numerical primitive a layer/network needs,...
Definition IComputeBackend.h:14
A 64-byte-aligned bump-pointer allocator over a single contiguous block of host memory....
Definition MemoryArena.h:141
Convolutional PC layer, precision-free, AdamW-capable, routed through IComputeBackend for GPU portabi...
Definition SimpleConvPCLayer.h:39
void Clamp(const std::vector< float > &input) noexcept
Clamps the flattened, batched input to the first (input) layer.
Definition SimpleConvPCNetwork.cpp:82
~SimpleConvPCNetwork()=default
void ProjectForward() noexcept
Seeds hidden layers from a genuine forward pass through current weights, instead of zero-init....
Definition SimpleConvPCNetwork.cpp:150
float TrainStepWithProjection(const std::vector< float > &x, const std::vector< float > &y, int inferenceSteps)
Full train step with forward-projection init: clamp input, project forward, clamp target,...
Definition SimpleConvPCNetwork.cpp:175
friend class PCNDiagnostics
Definition SimpleConvPCNetwork.h:129
std::vector< float > PredictWithProjection(const std::vector< float > &x, int inferenceSteps)
Inference-only counterpart to TrainStepWithProjection(): clamp input, project forward,...
Definition SimpleConvPCNetwork.cpp:195
float TrainStep(const std::vector< float > &x, const std::vector< float > &y, int inferenceSteps)
Full train step: clamp input+target, settle for inferenceSteps, update weights once,...
Definition SimpleConvPCNetwork.cpp:107
SimpleConvPCNetwork & operator=(const SimpleConvPCNetwork &)=delete
SimpleConvPCNetwork(const SimpleConvPCNetwork &)=delete
void ResetState() noexcept
Resets the beliefs (z) on every layer.
Definition SimpleConvPCNetwork.cpp:76
void Compile()
Sums every layer's required float count into a single contiguous arena and binds each layer into it....
Definition SimpleConvPCNetwork.cpp:44
void UpdateWeights() noexcept
Calls UpdateWeights() on every layer except the terminal one (each layer's own UpdateWeights() is als...
Definition SimpleConvPCNetwork.cpp:101
void RandomizeWeights(std::mt19937 &rng) noexcept
Initializes every layer's weights randomly.
Definition SimpleConvPCNetwork.cpp:70
void UpdateState() noexcept
Runs one settling step on every layer.
Definition SimpleConvPCNetwork.cpp:95
void AddLayer(int inChannels, int outChannels, int inHeight, int inWidth, int kernelH, int kernelW, int strideH=1, int strideW=1, int padH=0, int padW=0, float lr=1e-6f, float ir=0.1f, float lmbda=1e-2f, ActivationType aType=ActivationType::RELU, ActivationType dType=ActivationType::dRELU)
Adds a convolutional layer. Pass outChannels=0 to mark a terminal layer (no outgoing prediction),...
Definition SimpleConvPCNetwork.cpp:13
const auto & GetLayers() const noexcept
Returns every layer in the network, in the order they were added.
Definition SimpleConvPCNetwork.h:94
void SetOptimizer(OptimizerType opt) noexcept
Sets the optimizer for EVERY layer added so far. Safe to call any time before Compile() – unlike usin...
Definition SimpleConvPCNetwork.cpp:34
SimpleConvPCNetwork(int batchSize, DeviceType device=DeviceType::DEVICE_CPU) noexcept
Constructs an empty network; add layers via AddLayer(), then Compile() before use.
Definition SimpleConvPCNetwork.cpp:7
float CalculateState() noexcept
Computes and returns the network's total energy at the current state, without changing it.
Definition SimpleConvPCNetwork.cpp:87
SimpleConvPCLayer * GetTerminalLayer() noexcept
Returns the last layer (outChannels==0, the terminal one).
Definition SimpleConvPCNetwork.h:92
int GetBatchSize() const noexcept
Returns the batch size given at construction.
Definition SimpleConvPCNetwork.h:96
std::vector< float > Predict(const std::vector< float > &x, int inferenceSteps)
Clamps input only, settles, and returns the terminal layer's settled beliefs (flattened,...
Definition SimpleConvPCNetwork.cpp:126
This file exists to provide both Tensor.h and IComputeBackend.h with device types without introducing...
Definition Backend.cpp:10
ActivationType
Identifies an activation function or its derivative, for dispatch tables and layer/backend APIs that ...
Definition ActivationType.h:25
@ RELU
Definition ActivationType.h:26
@ dRELU
Definition ActivationType.h:27
OptimizerType
Selects which weight-update rule a layer applies during UpdateWeights().
Definition AdamOptimizer.h:52
@ SGD
Plain stochastic gradient descent (this codebase's existing cblas-based update).
Definition AdamOptimizer.h:53
DeviceType
Which physical device a Tensor/IComputeBackend pair runs on.
Definition DeviceType.h:8
@ DEVICE_CPU
Definition DeviceType.h:9