Sync public subset from Flux (private)
This commit is contained in:
42
include/modules/neural_networks/layers/dense_layer.h
Normal file
42
include/modules/neural_networks/layers/dense_layer.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user