LCOV - code coverage report
Current view: top level - include - LayerInput.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 12 13 92.3 %
Date: 2024-12-28 17:36:05 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /**
       2             :  * @file LayerInput.h
       3             :  * @author Damien Balima (www.dams-labs.net)
       4             :  * @brief Input layer
       5             :  * @date 2023-08-27
       6             :  *
       7             :  * @copyright Damien Balima (c) CC-BY-NC-SA-4.0 2023
       8             :  *
       9             :  */
      10             : #pragma once
      11             : #include "Layer.h"
      12             : #include <cstddef>
      13             : #include <stdexcept>
      14             : 
      15             : namespace sipai {
      16             : /**
      17             :  * @brief The InputLayer class represents the input layer of a neural network.
      18             :  * It inherits from the Layer class and overrides its methods as necessary. This
      19             :  * layer is responsible for receiving input from external sources.
      20             :  */
      21             : class LayerInput : public Layer {
      22             : public:
      23             :   LayerInput() : Layer(LayerType::LayerInput) {}
      24           8 :   LayerInput(size_t size_x, size_t size_y)
      25           8 :       : Layer(LayerType::LayerInput, size_x, size_y) {}
      26             : 
      27          61 :   void forwardPropagation() override {
      28             :     // No need to implement for input layer
      29          61 :   }
      30             : 
      31          42 :   void backwardPropagation(const float &error_min,
      32             :                            const float &error_max) override {
      33             :     // No need to implement for input layer (no weights of input layer)
      34          42 :   }
      35             : 
      36          42 :   void updateWeights(float learningRate) override {
      37             :     // No need to implement for input layer (no weights of input layer)
      38          42 :   }
      39             : 
      40          61 :   void setInputValues(const cv::Mat &inputValues) {
      41          61 :     if (inputValues.total() != total()) {
      42           0 :       throw std::invalid_argument("Invalid input values size");
      43             :     }
      44          61 :     values = inputValues;
      45          61 :   }
      46             : };
      47             : } // namespace sipai

Generated by: LCOV version 1.16