Add documentation comments

This commit is contained in:
2024-03-12 21:50:06 +01:00
parent 708164e4d0
commit 7157a27e56
9 changed files with 255 additions and 19 deletions

View File

@@ -10,8 +10,23 @@
namespace Layers {
/**
* @brief 2D convolutional layer
*
*/
class Conv2d : public ILayer {
public:
/**
* @brief Construct a new Conv 2d layer
*
* @param inputSize Width and height of the input matrix
* @param inputChannels Number of channels in the input matrix
* @param kernelSize Width and height of the convolution kernel
* @param stride Convolution stride
* @param padding Padding type ('SAME' or 'VALID')
* @param numFilters Number of output filters
* @param activation Activation function ('RELU', 'SIGMOID' or 'NONE')
*/
Conv2d(
int inputSize,
int inputChannels,
@@ -21,21 +36,57 @@ class Conv2d : public ILayer {
int numFilters,
Layers::Activation activation
);
/**
* @brief Destroy the Conv 2d object
*
*/
~Conv2d();
// Outputs
int outputSize;
/**
* @brief Forward pass of the convolutional layer
*
* @param d_input Device pointer to the input matrix
* @return Device pointer to the output matrix
*/
float* forward(const float* d_input);
void setWeights(const float* weights_input);
void setBiases(const float* biases_input);
void host_conv(const float* input, float* output);
/**
* @brief Set the weights of the convolutional layer
*
* @param weights_input Pointer to the weights
*/
void setWeights(const float* weights_input);
/**
* @brief Set the biases of the convolutional layer
*
* @param biases_input Pointer to the biases
*/
void setBiases(const float* biases_input);
/**
* @brief Get the output width (/ height) of the layer
*
* @return int
*/
int getOutputSize() { return outputSize; }
/**
* @brief Get the padding size of the layer
*
* @return int
*/
int getPaddingSize() { return paddingSize; }
private:
// Inputs
int inputSize;
int inputChannels;
// Outputs
int outputSize;
// Kernel
int kernelSize;
int stride;
@@ -55,8 +106,22 @@ class Conv2d : public ILayer {
// Kernels
Layers::Activation activation;
/**
* @brief Initialize weights of the convolutional layer with zeros
*
*/
void initializeWeights();
/**
* @brief Initialize biases of the convolutional layer with zeros
*
*/
void initializeBiases();
/**
* @brief Copy weights and biases to the device
*
*/
void toCuda();
};