25 const string& =
"Tanh",
27 const string& =
"dense_layer");
47 const string& =
"Tanh",
49 const string& =
"dense_layer");
70 const vector<string>& output_names)
const override;
74 Index output_features = 0;
81 enum Forward {Input, CombinationView, BatchNormMean, BatchNormInverseVariance, ActivationView, Output};
83 void configure_operators();
void set_dropout_rate(float new_dropout_rate)
Definition dense_layer.h:61
void read_JSON_body(const Json *) override
Subclass hook reading the body section of the layer's JSON node.
void set_activation_function(const string &)
Sets the activation function from its string name (e.g. "Tanh", "Logistic", "Linear").
string write_expression(const vector< string > &input_names, const vector< string > &output_names) const override
Returns a human-readable mathematical expression for this layer (empty by default).
void set_batch_normalization(bool enable)
Enables or disables batch normalization on the layer combination output.
void set_input_shape(const Shape &) override
Sets the input shape; subclasses override to derive dependent dimensions.
void set_momentum(float new_momentum)
Sets the running-statistics momentum used by batch normalization.
float get_momentum() const
Definition dense_layer.h:39
Dense(const Shape &={}, const Shape &={}, const string &="Tanh", bool=false, const string &="dense_layer")
Constructs a dense layer with the given input/output shapes, activation, and batch-norm flag.
void on_compute_dtype_changed() override
Subclass hook invoked when the compute dtype changes; default is no-op.
Definition dense_layer.h:55
Shape get_output_shape() const override
Returns the layer output shape, derived from input shape and configured output features.
bool get_batch_normalization() const
Definition dense_layer.h:38
vector< TensorSpec > get_forward_specs(Index batch_size) const override
Returns the tensor specs of intermediate forward buffers for a given batch size.
void set_output_shape(const Shape &) override
Sets the output shape; subclasses override when the output is user-configurable.
Index get_sequence_length() const
Definition dense_layer.h:33
const ActivationOp::Function & get_activation_function() const
Definition dense_layer.h:35
void set(const Shape &={}, const Shape &={}, const string &="Tanh", bool=false, const string &="dense_layer")
Reconfigures the layer with new shapes, activation, batch-normalization flag and label.
ActivationOp::Function get_output_activation() const override
Returns the layer's output activation (Identity for most layers; overridden by Dense/Bounding).
Definition dense_layer.h:36
Index get_input_features() const
Definition dense_layer.h:32
Shape input_shape
Definition layer.h:256
Definition adaptive_moment_estimation.h:14
Element-wise non-linear activation (Identity, Sigmoid, Tanh, ReLU, Softmax).
Definition operators.h:169
Function
Supported activation functions.
Definition operators.h:171
Batch normalization with learnable scale/shift and running statistics for inference.
Definition operators.h:308
Affine combination output = input * weights + bias (the dense matmul building block).
Definition operators.h:232
Inverted dropout: at training time zeros activations with probability rate and rescales survivors.
Definition operators.h:122
Fixed-capacity small-vector describing tensor dimensions (rank up to MaxRank).
Definition tensor_utilities.h:42