mirror of
https://github.com/augustin64/projet-tipe
synced 2025-03-13 06:15:21 +01:00
Fix softmax_backward
This commit is contained in:
parent
67e92e9736
commit
c1283d8c4b
@ -14,16 +14,11 @@ int max(int a, int b) {
|
||||
}
|
||||
|
||||
// Euh..... tout peut être faux à cause de la source
|
||||
void rms_backward(float* input, float* input_z, float* output, int size) {
|
||||
void softmax_backward(float* input, float* input_z, float* output, int size) {
|
||||
/* Input et output ont la même taille
|
||||
On considère que la dernière couche a utilisée softmax */
|
||||
float sum=0;
|
||||
for (int i=0; i < size; i++)
|
||||
sum += exp(input_z[i]);
|
||||
float denom = sum*sum;
|
||||
for (int i=0; i < size; i++){
|
||||
float e_i = exp(input_z[i]);
|
||||
input[i] = 2*(input[i]-output[i])*((e_i*(sum-e_i))/denom); // ∂E/∂out_i * ∂out_i/∂net_i = 𝛿_i
|
||||
input[i] = (output[i]-input[i])*input[i]; // ∂E/∂out_i * ∂out_i/∂net_i = 𝛿_i
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ void backward_propagation(Network* network, float wanted_number) {
|
||||
float*** output;
|
||||
Kernel* k_i;
|
||||
|
||||
rms_backward(network->input[n-1][0][0], network->input_z[n-1][0][0], wanted_output, network->width[n-1]); // Backward sur la dernière colonne
|
||||
softmax_backward(network->input[n-1][0][0], network->input_z[n-1][0][0], wanted_output, network->width[n-1]); // Backward sur la dernière colonne
|
||||
|
||||
for (int i=n-2; i >= 0; i--) {
|
||||
// Modifie 'k_i' à partir d'une comparaison d'informations entre 'input' et 'output'
|
||||
|
@ -17,7 +17,7 @@ int max(int a, int b);
|
||||
/*
|
||||
* Transfert les informations d'erreur de la sortie voulue à la sortie réelle
|
||||
*/
|
||||
void rms_backward(float* input, float* input_z, float* output, int size);
|
||||
void softmax_backward(float* input, float* input_z, float* output, int size);
|
||||
|
||||
/*
|
||||
* Transfert les informations d'erreur à travers une couche d'average pooling
|
||||
|
Loading…
x
Reference in New Issue
Block a user