Started Loss, done softmax, up to p.125
I've implemented alot of support functions that needs to be refactored, optimised and tested; mean.h, exponential.h, matdiv.h matsum.h matsubtract.h. Maybe we need to have a look at if matdiv/matmul should be in the same. Same with matadd/matsubtract and if some of it should be in matvec.h.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#ifndef _mean_n_
|
||||
#define _mean_n_
|
||||
|
||||
#include "./utils/vector.h"
|
||||
#include "./utils/matrix.h"
|
||||
#include "./core/omp_config.h"
|
||||
|
||||
namespace numerics{
|
||||
|
||||
template <typename T>
|
||||
T mean(utils::Vector<T>& A) {
|
||||
|
||||
T mean(T{0});
|
||||
|
||||
const uint64_t rows = A.rows();
|
||||
const uint64_t cols = A.cols();
|
||||
|
||||
|
||||
for (uint64_t i = 0; i < cols; ++i) {
|
||||
for (uint64_t j = 0; j < rows; ++j) {
|
||||
mean += A(j, i);
|
||||
}
|
||||
}
|
||||
mean /= (static_cast<T>(rows)* static_cast<T>(cols));
|
||||
return mean;
|
||||
}
|
||||
|
||||
|
||||
} // namespace numerics
|
||||
|
||||
#endif // _mean_n_
|
||||
Reference in New Issue
Block a user