First Commit!

This commit is contained in:
Joseph Redmon
2013-11-04 11:11:01 -08:00
commit 41bcfac86f
18 changed files with 954 additions and 0 deletions

48
src/network.c Normal file
View File

@ -0,0 +1,48 @@
#include "network.h"
#include "image.h"
#include "connected_layer.h"
#include "convolutional_layer.h"
#include "maxpool_layer.h"
void run_network(image input, network net)
{
int i;
double *input_d = 0;
for(i = 0; i < net.n; ++i){
if(net.types[i] == CONVOLUTIONAL){
convolutional_layer layer = *(convolutional_layer *)net.layers[i];
run_convolutional_layer(input, layer);
input = layer.output;
input_d = layer.output.data;
}
else if(net.types[i] == CONNECTED){
connected_layer layer = *(connected_layer *)net.layers[i];
run_connected_layer(input_d, layer);
input_d = layer.output;
}
else if(net.types[i] == MAXPOOL){
maxpool_layer layer = *(maxpool_layer *)net.layers[i];
run_maxpool_layer(input, layer);
input = layer.output;
input_d = layer.output.data;
}
}
}
image get_network_image(network net)
{
int i;
for(i = net.n-1; i >= 0; --i){
if(net.types[i] == CONVOLUTIONAL){
convolutional_layer layer = *(convolutional_layer *)net.layers[i];
return layer.output;
}
else if(net.types[i] == MAXPOOL){
maxpool_layer layer = *(maxpool_layer *)net.layers[i];
return layer.output;
}
}
return make_image(1,1,1);
}