Started on regulaization in Loss.h. I need to refactor the matsum.h since I need a total sum over the matrix. Also matmul needs a elementwise matmul function, which is the next this in the ragulaization
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "./numerics/abs.h"
|
||||
#include "./utils/matrix.h"
|
||||
|
||||
namespace numerics{
|
||||
|
||||
template <typename T>
|
||||
void inplace_matabs(utils::Matrix<T>& A){
|
||||
|
||||
for (uint64_t i = 0; i < A.rows(); ++i){
|
||||
for (uint64_t j = 0; j < A.cols(); ++j){
|
||||
A(i,j) = numerics::abs(A(i,j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
utils::Matrix<T> matabs(const utils::Matrix<T>& A){
|
||||
utils::Matrix<T> B = A;
|
||||
inplace_matabs(B);
|
||||
return B;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace numerics
|
||||
|
||||
Reference in New Issue
Block a user