probably how maxpool layers should be

This commit is contained in:
Joseph Redmon
2014-08-08 12:04:15 -07:00
parent b32a287e38
commit d9f1b0b16e
32 changed files with 1044 additions and 746 deletions

View File

@ -1,4 +1,5 @@
#include "softmax_layer.h"
#include "mini_blas.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
@ -11,6 +12,7 @@ softmax_layer *make_softmax_layer(int batch, int inputs)
layer->inputs = inputs;
layer->output = calloc(inputs*batch, sizeof(float));
layer->delta = calloc(inputs*batch, sizeof(float));
layer->jacobian = calloc(inputs*inputs*batch, sizeof(float));
return layer;
}
@ -51,6 +53,28 @@ void forward_softmax_layer(const softmax_layer layer, float *input)
void backward_softmax_layer(const softmax_layer layer, float *input, float *delta)
{
/*
int i,j,b;
for(b = 0; b < layer.batch; ++b){
for(i = 0; i < layer.inputs; ++i){
for(j = 0; j < layer.inputs; ++j){
int d = (i==j);
layer.jacobian[b*layer.inputs*layer.inputs + i*layer.inputs + j] =
layer.output[b*layer.inputs + i] * (d - layer.output[b*layer.inputs + j]);
}
}
}
for(b = 0; b < layer.batch; ++b){
int M = layer.inputs;
int N = 1;
int K = layer.inputs;
float *A = layer.jacobian + b*layer.inputs*layer.inputs;
float *B = layer.delta + b*layer.inputs;
float *C = delta + b*layer.inputs;
gemm(0,0,M,N,K,1,A,K,B,N,0,C,N);
}
*/
int i;
for(i = 0; i < layer.inputs*layer.batch; ++i){
delta[i] = layer.delta[i];