https://github.com/dattali18/cpp-math-library
This is a repo for learning to code a math library in cpp to 1. better my cpp skills 2. better my deep-learning & ML understanding
https://github.com/dattali18/cpp-math-library
cmake cpp deep-learning ml neural-network
Last synced: 12 months ago
JSON representation
This is a repo for learning to code a math library in cpp to 1. better my cpp skills 2. better my deep-learning & ML understanding
- Host: GitHub
- URL: https://github.com/dattali18/cpp-math-library
- Owner: dattali18
- Created: 2024-05-26T09:17:10.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-05T15:53:10.000Z (about 2 years ago)
- Last Synced: 2025-02-25T22:46:54.815Z (over 1 year ago)
- Topics: cmake, cpp, deep-learning, ml, neural-network
- Language: C++
- Homepage:
- Size: 72.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Math Library
In this project we will be building a math library in `cpp`
This library will be used in building simple Neural Network library in the future.
## Structure
The library will be divided into the following parts:
1. Vector
2. Matrix
3. Activation Functions
4. Layer
5. Linear Regression
6. Logistic Regression
## UML
```mermaid
classDiagram
class Vector {
+Vector(size_t size)
+Vector(const std::vector~double~& data)
+Vector(const Vector& other)
-std::vector~double~ data_
}
class Matrix {
+Matrix(size_t rows, size_t cols)
+Matrix(const std::vector~std::vector~double~~& data)
+Matrix(const Vector& vec)
+Matrix mult(const Matrix& other) const
+Matrix transpose() const
-std::vector~std::vector~double~~ data_
}
class Activation {
<>
+double call(double x) const
+double derivative(double x) const
}
class ReLU_ {
+double call(double x) const
+double derivative(double x) const
}
class Sigmoid_ {
+double call(double x) const
+double derivative(double x) const
}
class Tanh_ {
+double call(double x) const
+double derivative(double x) const
}
class Functions {
+static Activation* ReLU
+static Activation* Sigmoid
+static Activation* Tanh
}
class Layer {
+Layer(size_t input_size, size_t output_size)
+Vector forward(const Vector& input)
+void backward(const Vector& grad, double learning_rate)
-Matrix weights_
-Vector biases_
-Vector last_input_
-Vector last_output_
-Activation* activation_
}
class LinearRegression {
+LinearRegression(std::vector& x, std::vector& y)
+void fit()
+Vector predict(std::vector& x)
-std::vector x_
-std::vector y_
-Vector theta_
-double beta_
}
class LogisticRegression {
+LogisticRegression(std::vector& x, std::vector& y)
+void fit(std::vector& x, std::vector& y)
+Vector predict(std::vector& x)
-std::vector x_
-std::vector y_
-Vector theta_
-double beta_
}
Vector --> Matrix
Matrix --> Vector
Layer --> Matrix
Layer --> Vector
Layer --> Activation
Activation <|-- ReLU_
Activation <|-- Sigmoid_
Activation <|-- Tanh_
Functions --> Activation
LinearRegression --> Vector
LogisticRegression --> Vector
```