Files
Flux/include/modules/neural_networks/layers/dense_layer.h
T
Bausager ea359f3b09 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.
2025-10-05 19:47:56 +02:00

42 lines
821 B
C++

#pragma once
#include "./core/omp_config.h"
#include "./utils/vector.h"
#include "./utils/matrix.h"
#include "./utils/random.h"
namespace neural_networks{
template <typename T>
struct dense_layer{
utils::Matrix<T> weights;
utils::Vector<T> biases;
utils::Matrix<T> outputs;
// Default Constructor
dense_layer() = default;
// Constructor
dense_layer(const uint64_t n_inputs, const uint64_t n_neurons){
weights.random(n_inputs, n_neurons, -1, 1);
biases.resize(n_neurons, T{0});
//weights.print();
//outputs.resize()
}
void forward(utils::Matrix<T> inputs){
outputs = numerics::matadd(numerics::matmul_auto(inputs, (weights)), biases, "row");
}
};
} // end namespace neural_networks