8#include <initializer_list>
73 void set_bias(std::initializer_list<float> values);
77 [[nodiscard]]
const Tensor&
bias()
const {
return bias_; }
98 {
"weight_xh", {&weight_xh_, &weight_xh_grad_}},
99 {
"weight_hh", {&weight_hh_, &weight_hh_grad_}},
100 {
"bias", {&bias_, &bias_grad_}},
120 int64_t hidden_size_;
129 Tensor last_hidden_states_;
130 Tensor last_pre_activation_;
132 bool has_forwarded_ =
false;
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:219
virtual DeviceType device() const noexcept=0
Which device this backend's buffers reside on.
Base class for every layer type (LinearModule, Conv2DModule, activations, ...).
Definition module.hpp:58
h_t = tanh(x_t @ W_xh + h_{t-1} @ W_hh + b_h), h_0 = 0 (zero-initialized, not learnable – a deliberat...
Definition rnn_module.hpp:37
void set_bias(std::initializer_list< float > values)
Overwrites the hidden bias buffer – test/initialization use only.
const Tensor & weight_hh() const
Definition rnn_module.hpp:76
const Tensor & bias() const
Definition rnn_module.hpp:77
const Tensor & weight_xh_grad() const
Definition rnn_module.hpp:78
void set_weight_xh(std::initializer_list< float > values)
Overwrites the input-to-hidden weight buffer – test/initialization use only.
Tensor forward_impl(const Tensor &input) override
The actual forward computation – per-timestep tied-weight recurrence.
std::vector< NamedParamRef > named_parameters() override
This module's trainable parameters, each with its hierarchical name – the one place a module declares...
Definition rnn_module.hpp:96
RNNModule(int64_t input_size, int64_t hidden_size, DeviceBackend *backend)
Constructs an RNN layer with zero-initialized weights/bias.
const Tensor & bias_grad() const
Definition rnn_module.hpp:80
Tensor propagate_relevance(const Tensor &relevance_out, const LRPRuleConfig &config) override
Epsilon/z-rule LRP relevance propagation, generalized to two weighted sources, tanh treated as identi...
const Tensor & weight_xh() const
Definition rnn_module.hpp:75
void set_weight_hh(std::initializer_list< float > values)
Overwrites the hidden-to-hidden weight buffer – test/initialization use only.
std::optional< DeviceType > compute_device() const override
Where this layer computes, so forward() rejects an input on another device (FND-8).
Definition rnn_module.hpp:106
Tensor backward(const Tensor &grad_output) override
Real backpropagation-through-time (BPTT): accumulates W_xh/W_hh/b_h gradients across every timestep i...
OpType op_type() const override
Recurrent per charter's closed OpType set – a compound accumulate-over-time operation,...
Definition rnn_module.hpp:66
const Tensor & weight_hh_grad() const
Definition rnn_module.hpp:79
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Abstract base every layer subclasses – NVI forward(), pure-virtual LRP contract.
Definition acquisition_functions.hpp:16
OpType
The op-type tag a Node carries. Charter Part 2 §3: nodes are tagged by a small closed set of op types...
Definition op_type.hpp:19
Configuration for LRP relevance propagation: which rule a module applies and its hyperparameters....
Definition lrp_rule_config.hpp:57