Done with activation softmax backwards
This commit is contained in:
@@ -43,6 +43,9 @@
|
||||
#include <math/add.hpp>
|
||||
#include <random/uniform.hpp>
|
||||
|
||||
#include <math/transpose.hpp>
|
||||
#include <math/sum.hpp>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// PRIVATE CONSTANTS
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -70,7 +73,8 @@ namespace panic{
|
||||
layer_dense::layer_dense() {
|
||||
weights.resize(0,0);
|
||||
biases.resize(0);
|
||||
outputs.resize(0,0);
|
||||
dweights.resize(0,0);
|
||||
dbiases.resize(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -86,9 +90,7 @@ layer_dense::layer_dense(panic::types::uint_t input_size, panic::types::uint_t n
|
||||
|
||||
biases.resize(neurons);
|
||||
biases.fill(0);
|
||||
//panic::random::uniform(biases);
|
||||
|
||||
outputs.resize(0,0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +101,9 @@ layer_dense::layer_dense(panic::types::uint_t input_size, panic::types::uint_t n
|
||||
// Calculated the forward pass:
|
||||
// outputs = inputs * weights + biases
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool layer_dense::forward(const panic::tensor::real_matrix& inputs){
|
||||
bool layer_dense::forward(const panic::tensor::real_matrix& input_data){
|
||||
|
||||
inputs = input_data;
|
||||
|
||||
if (inputs.cols() != weights.rows()){
|
||||
return false;
|
||||
@@ -128,9 +132,16 @@ bool layer_dense::forward(const panic::tensor::real_matrix& inputs){
|
||||
// Calculated the backward pass:
|
||||
// ??
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool layer_dense::backward(const panic::tensor::real_matrix& dinputs){
|
||||
bool layer_dense::backward(const panic::tensor::real_matrix& dvalues){
|
||||
|
||||
|
||||
// Gradients on parameters
|
||||
dweights = panic::math::matmul(panic::math::transpose(inputs), dvalues);
|
||||
dbiases = panic::math::sum_colwise(dvalues);
|
||||
|
||||
// Gradients on values
|
||||
dinputs = panic::math::matmul(dvalues, panic::math::transpose(weights));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user