|
OpenNN
Open-source neural networks library
|
Element-wise non-linear activation (Identity, Sigmoid, Tanh, ReLU, Softmax). More...
#include <operators.h>
Public Types | |
| enum class | Function { Identity , Sigmoid , Tanh , ReLU , Softmax } |
| Supported activation functions. More... | |
Public Member Functions | |
| void | set_function (Function new_function) |
| Selects the activation function and configures cuDNN descriptors. | |
| void | set_function (const string &name) |
| Selects the activation function by name (delegates to set_function(Function)). | |
| void | forward_propagate (ForwardPropagation &fp, size_t layer, bool is_training) noexcept override |
| Runs the operator's forward computation. | |
| void | back_propagate (ForwardPropagation &fp, BackPropagation &bp, size_t layer) const noexcept override |
| Runs the operator's backward computation, accumulating into gradient/delta buffers. | |
| void | apply_cpu (TensorView &output) |
CPU forward implementation; applies the activation in place on output. | |
| void | apply_gpu (TensorView &output) |
GPU forward implementation; applies the activation in place on output. | |
| void | apply_delta (const TensorView &outputs, TensorView &delta) const |
Multiplies delta by the derivative of the activation evaluated at outputs. | |
| void | to_JSON (JsonWriter &w) const override |
| Serializes the operator configuration to a JSON writer. | |
| void | from_JSON (const Json *parent) override |
| Restores the operator configuration from a JSON node. | |
| void | destroy_cuda () override |
| Releases CUDA resources owned by the operator; called from destructors. | |
| ~ActivationOp () override | |
| ActivationOp ()=default | |
| ActivationOp (const ActivationOp &)=delete | |
| ActivationOp & | operator= (const ActivationOp &)=delete |
Public Member Functions inherited from opennn::Operator | |
| virtual | ~Operator ()=default |
| virtual vector< TensorSpec > | parameter_specs () const |
| Returns the tensor specs of trainable parameters owned by this operator. | |
| virtual vector< TensorSpec > | state_specs () const |
| Returns the tensor specs of persistent state owned by this operator. | |
| virtual void | link_parameters (span< const TensorView >) |
| Binds parameter views provided by the hosting layer. | |
| virtual void | link_gradients (span< const TensorView >) |
| Binds gradient views provided by the hosting layer. | |
| virtual void | link_states (span< const TensorView >) |
| Binds state views provided by the hosting layer. | |
| virtual void | set_parameters_random () |
| Initializes parameters with random values. | |
| virtual void | set_parameters_glorot () |
| Initializes parameters using Glorot (Xavier) initialization. | |
| virtual void | load_state_from_JSON (const Json *) |
| Restores persistent state (e.g. running statistics) from a JSON node. | |
| TensorView & | get_input (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept |
| vector< TensorView > & | get_inputs (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept |
| TensorView & | get_output (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept |
| TensorView & | get_output_delta (BackPropagation &bp, size_t layer, size_t i=0) const noexcept |
| TensorView & | get_input_delta (BackPropagation &bp, size_t layer, size_t i=0) const noexcept |
Static Public Member Functions | |
| static const EnumMap< Function > & | map () |
| Returns the bidirectional mapping between Function values and their string names. | |
| static Function | from_string (const string &name) |
| Returns the Function corresponding to a string name. | |
| static const string & | to_string (Function function) |
| Returns the string name of a Function. | |
| static cudnnActivationMode_t | to_cudnn_mode (Function function) |
| Returns the cuDNN activation mode corresponding to a Function. | |
Public Attributes | |
| Function | function = Function::Identity |
| cudnnActivationDescriptor_t | descriptor = nullptr |
| vector< size_t > | output_slots_backward |
Public Attributes inherited from opennn::Operator | |
| vector< size_t > | input_slots = {0} |
| vector< size_t > | output_slots = {1} |
| vector< size_t > | input_delta_slots = {1} |
| vector< size_t > | output_delta_slots = {0} |
Element-wise non-linear activation (Identity, Sigmoid, Tanh, ReLU, Softmax).
|
strong |
|
inlineoverride |
|
default |
|
delete |
| void opennn::ActivationOp::apply_cpu | ( | TensorView & | output | ) |
CPU forward implementation; applies the activation in place on output.
| void opennn::ActivationOp::apply_delta | ( | const TensorView & | outputs, |
| TensorView & | delta ) const |
Multiplies delta by the derivative of the activation evaluated at outputs.
| void opennn::ActivationOp::apply_gpu | ( | TensorView & | output | ) |
GPU forward implementation; applies the activation in place on output.
|
overridevirtualnoexcept |
Runs the operator's backward computation, accumulating into gradient/delta buffers.
| fp | Forward propagation workspace (read-only). |
| bp | Back propagation workspace receiving gradients and deltas. |
| layer | Index of the hosting layer in the workspace. |
Reimplemented from opennn::Operator.
|
overridevirtual |
Releases CUDA resources owned by the operator; called from destructors.
Reimplemented from opennn::Operator.
|
overridevirtualnoexcept |
Runs the operator's forward computation.
| fp | Forward propagation workspace. |
| layer | Index of the hosting layer in the workspace. |
| is_training | If true, enables training-only behavior (e.g. dropout sampling). |
Reimplemented from opennn::Operator.
|
overridevirtual |
Restores the operator configuration from a JSON node.
Reimplemented from opennn::Operator.
|
static |
Returns the Function corresponding to a string name.
Returns the bidirectional mapping between Function values and their string names.
|
delete |
| void opennn::ActivationOp::set_function | ( | const string & | name | ) |
Selects the activation function by name (delegates to set_function(Function)).
| void opennn::ActivationOp::set_function | ( | Function | new_function | ) |
Selects the activation function and configures cuDNN descriptors.
|
static |
Returns the cuDNN activation mode corresponding to a Function.
|
overridevirtual |
Serializes the operator configuration to a JSON writer.
Reimplemented from opennn::Operator.
|
static |
Returns the string name of a Function.
| cudnnActivationDescriptor_t opennn::ActivationOp::descriptor = nullptr |
| Function opennn::ActivationOp::function = Function::Identity |
| vector<size_t> opennn::ActivationOp::output_slots_backward |