MLask 1.0.0
A custom c++ deep learning library
Loading...
Searching...
No Matches
Layer.hpp
Go to the documentation of this file.
1#pragma once
2#include <Eigen/Core>
3#include <Eigen/Dense>
4#include "types.hpp"
5#include "onnx/onnx_pb.h"
6
7namespace mlask {
8
10class Layer {
11protected:
12 std::size_t in_;
13 std::size_t out_;
14 public:
15 std::size_t getIn()const{ return in_; }
16 std::size_t getOut()const{ return out_; }
17
18 virtual ~Layer() = default;
24 virtual void fit(float_t learning_rate) = 0;
26 virtual bool tryConvertToONNX(onnx::GraphProto* graph, std::string input, std::string output)const { return false; }
28 virtual std::string str()const{ return "Layer"; }
29};
30
32template <typename T>
33concept TLayer= std::derived_from<T, Layer>;
34} // namespace mlask
Base class for all layers in the neural network.
Definition Layer.hpp:10
virtual std::string str() const
Returns a string representation of the layer.
Definition Layer.hpp:28
std::size_t in_
Definition Layer.hpp:12
std::size_t out_
Definition Layer.hpp:13
virtual void fit(float_t learning_rate)=0
Describes how the layer 'learns', meaning it defines how layer updates itself.
virtual vectorIn backward(vectorOut)=0
Defines a way to backpropagate error in backropagation algorithm.
virtual vectorOut forward(vectorIn)=0
Defines a way to move forward in a neural network.
virtual bool tryConvertToONNX(onnx::GraphProto *graph, std::string input, std::string output) const
Converts the layer to ONNX format. If the layer cannot be converted, it should return false.
Definition Layer.hpp:26
std::size_t getIn() const
Definition Layer.hpp:15
virtual ~Layer()=default
std::size_t getOut() const
Definition Layer.hpp:16
concept ensuring a class derives from Layer
Definition Layer.hpp:33
Definition LeakyRelu.hpp:4
Eigen::Matrix< float_t, Eigen::Dynamic, 1 > vectorOut
Definition types.hpp:17
float float_t
Definition types.hpp:12
Eigen::Matrix< float_t, Eigen::Dynamic, 1 > vectorIn
Definition types.hpp:16