|
pulsatrix
|
y = 1 - x, elementwise. No parameters, no parameter gradients.
More...
#include <negation_module.hpp>


Public Member Functions | |
| NegationModule (DeviceBackend *backend) | |
| Constructs a negation module. | |
| Tensor | backward (const Tensor &grad_output) override |
Gradient w.r.t. this module's input: dy/dx = -1, so grad_x = -grad_output. | |
| OpType | op_type () const override |
| Elementwise per this module's own single-input, weight-free operation. | |
| Tensor | propagate_relevance (const Tensor &relevance_out, const LRPRuleConfig &config) override |
| LRP relevance propagation: pass-through, unchanged. | |
| std::optional< DeviceType > | compute_device () const override |
| Where this layer computes, so forward() rejects an input on another device (FND-8). | |
Public Member Functions inherited from pulsatrix::Module | |
| virtual | ~Module ()=default |
| Tensor | forward (const Tensor &input) |
| Runs this module's forward computation. | |
| std::pair< Tensor, NodeId > | forward_traced (const Tensor &input, NodeId input_node, ComputationGraph &graph, Autograd &autograd) |
| Runs forward() while also registering a ComputationGraph node (tagged with this module's op_type(), parented to input_node) and wiring an Autograd backward function that reuses this module's own backward() – the opt-in traced/explainable path, per Phase 2 Mission 0. | |
| virtual bool | supports_lrp_rule (LRPRule rule) const |
Whether propagate_relevance() implements rule (no silent fallback: callers such as ExplainerContext::relevance_pass() throw rather than run a module on a rule it does not implement). | |
| virtual std::vector< NamedParamRef > | named_parameters () |
| This module's trainable parameters, each with its hierarchical name – the one place a module declares its parameters (roadmap FND-1). | |
| virtual std::vector< ParamRef > | parameters () |
| This module's trainable parameters and their gradients, for an optimizer to update uniformly across module types. | |
| void | set_requires_grad (bool requires_grad, const std::string &prefix="") |
Freezes (false) or unfreezes (true) parameters by name (roadmap FND-2). | |
| virtual void | set_training (bool training) |
| Sets this module's training/eval mode. Defaults to training (matches every mainstream framework's Module default). | |
| bool | is_training () const |
| Whether this module is currently in training mode. | |
Protected Member Functions | |
| Tensor | forward_impl (const Tensor &input) override |
| The actual forward computation. Called by forward() after precondition checks. | |
y = 1 - x, elementwise. No parameters, no parameter gradients.
|
explicit |
Constructs a negation module.
| backend | Backend to allocate/compute through. Not owned; must outlive this module. |
Gradient w.r.t. this module's input: dy/dx = -1, so grad_x = -grad_output.
| grad_output | Gradient w.r.t. this module's output. Must match the shape of the most recent forward() call's output. |
| std::logic_error | if called before any forward(). |
| std::invalid_argument | if grad_output's shape differs from the cached forward shape. |
Implements pulsatrix::Module.
|
inlineoverridevirtual |
Where this layer computes, so forward() rejects an input on another device (FND-8).
Reimplemented from pulsatrix::Module.
The actual forward computation. Called by forward() after precondition checks.
Implements pulsatrix::Module.
|
inlineoverridevirtual |
Elementwise per this module's own single-input, weight-free operation.
Implements pulsatrix::Module.
|
overridevirtual |
LRP relevance propagation: pass-through, unchanged.
1 - x passes relevance through unchanged, exactly like ReluModule's pointwise nonlinearity does. The 1 in y = -x + 1 is a constant bias, absorbed rather than distributed – same bias-exclusion convention LinearModule's own epsilon rule already uses (its denominator is the pre-bias z_j, not the post-bias output). Implements pulsatrix::Module.