1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/// Enumeration representing different types of training parameters for neural network layers.
///
/// This enum categorizes layers based on their parameter training capabilities:
/// - Layers with trainable parameters (e.g., Dense, Convolutional layers)
/// - Layers without trainable parameters (e.g., Pooling, Activation layers)
/// - Special layers that have no parameters at all
///
/// # Variants
///
/// - `Trainable(usize)` - The layer has trainable parameters, with the count specified by the `usize` value
/// - `NonTrainable(usize)` - The layer has parameters but they are not trainable (e.g., frozen layers)
/// - `NoTrainable` - The layer has no trainable parameters (e.g., pooling layers, activation functions)
/// A macro that generates standard function implementations for neural network layers
/// without trainable parameters.
///
/// # Parameters
///
/// - `$param_count`: Returns 0 as the layer has no trainable parameters
/// - `$update_parameters_sgd`: Empty implementation for SGD parameter updates
/// - `$update_parameters_adam`: Empty implementation for Adam parameter updates
/// - `$update_parameters_rmsprop`: Empty implementation for RMSProp parameter updates
/// - `$get_weights`: Returns `LayerWeight::Empty` as the layer has no weights
/// A macro that conditionally executes parallel or sequential computation based on a threshold.
///
/// This macro is designed to eliminate code duplication in both convolution and pooling layers
/// by providing a unified pattern for choosing between parallel and sequential execution strategies.
///
/// # Parameters
///
/// - `$batch_size` - Number of batches
/// - `$channels` - Number of channels
/// - `$threshold` - Threshold for parallel execution (when batch_size * channels >= threshold)
/// - `$compute_fn` - Closure/function to execute for each (batch, channel) pair
/// A macro that merges gradient results back into the gradient tensor for 1D spatial data.
///
/// This macro handles the common pattern of writing computed spatial gradients
/// back to the gradient tensor for 1D pooling and convolution layers.
///
/// # Parameters
///
/// - `$grad_tensor` - The gradient tensor to write to
/// - `$results` - Iterator of results in format ((batch, channel), spatial_grad)
/// - `$length` - Length of the spatial dimension
/// A macro that merges gradient results back into the gradient tensor for 2D spatial data.
///
/// This macro handles the common pattern of writing computed spatial gradients
/// back to the gradient tensor for 2D pooling and convolution layers.
///
/// # Parameters
///
/// - `$grad_tensor` - The gradient tensor to write to
/// - `$results` - Iterator of results in format ((batch, channel), spatial_grad)
/// - `$height` - Height of the spatial dimension
/// - `$width` - Width of the spatial dimension
/// A macro that merges gradient results back into the gradient tensor for 3D spatial data.
///
/// This macro handles the common pattern of writing computed spatial gradients
/// back to the gradient tensor for 3D pooling and convolution layers.
///
/// # Parameters
///
/// - `$grad_tensor` - The gradient tensor to write to
/// - `$results` - Iterator of results in format ((batch, channel), spatial_grad)
/// - `$depth` - Depth of the spatial dimension
/// - `$height` - Height of the spatial dimension
/// - `$width` - Width of the spatial dimension
/// A module containing activation layer implementations for neural networks
/// Convolutional layer for neural networks
/// Dense (Fully Connected) layer implementation for neural networks
/// A layer that flattens a 4D tensor into a 2D tensor
/// A module containing helper functions for neural network layers
/// Container for different types of neural network layer weights
/// Pooling layer for neural networks
/// Recurrent layer for neural networks
/// A module containing regularization layers for neural networks
/// A module containing helper functions and structs for serializing neural network weights
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;