Starting on the model.h, but need to make layer structs and structs for loss and optimizers

This commit is contained in:
2026-05-30 09:13:52 +02:00
parent cb65174cf4
commit edad247227
30 changed files with 1879 additions and 159 deletions
+48
View File
@@ -0,0 +1,48 @@
#pragma once
#include <cstdint> //uint64_t
#include <cmath> // std::abs
#include "utils/vector.h"
#include "utils/matrix.h"
namespace numerics::detail{
template <typename T>
void inplace_sign_serial(T& c) {
if (c < T{0}){
c = T{-1};
}
else if(c > T{0}){
c = T{1};
}
else{
c = T{0};
}
}
template <typename T>
void inplace_sign_serial(utils::Vector<T>& v) {
const uint64_t n = v.size();
for (uint64_t i = 0; i < n; ++i){
inplace_sign_serial(v[i]);
}
}
template <typename T>
void inplace_sign_serial(utils::Matrix<T>& A) {
const uint64_t rows = A.rows();
const uint64_t cols = A.cols();
for (uint64_t i = 0; i < rows; ++i){
for (uint64_t j = 0; j < cols; ++j){
inplace_sign_serial(A(i,j));
}
}
}
} // namespace numerics