darknet/src/layer.h

240 lines
4.3 KiB
C
Raw Normal View History

2015-05-11 23:54:58 +03:00
#ifndef BASE_LAYER_H
#define BASE_LAYER_H
#include "activations.h"
2016-05-13 21:59:43 +03:00
#include "stddef.h"
2015-05-11 23:54:58 +03:00
2015-12-14 22:57:10 +03:00
struct layer;
typedef struct layer layer;
2015-05-11 23:54:58 +03:00
typedef enum {
CONVOLUTIONAL,
DECONVOLUTIONAL,
CONNECTED,
MAXPOOL,
SOFTMAX,
DETECTION,
DROPOUT,
CROP,
ROUTE,
2015-07-10 01:22:14 +03:00
COST,
2015-07-14 01:04:21 +03:00
NORMALIZATION,
2015-11-14 23:34:17 +03:00
AVGPOOL,
2015-12-14 22:57:10 +03:00
LOCAL,
2016-01-19 02:40:14 +03:00
SHORTCUT,
2016-01-28 23:30:38 +03:00
ACTIVE,
2016-03-01 00:54:12 +03:00
RNN,
2016-05-07 02:25:16 +03:00
GRU,
CRNN,
BATCHNORM,
NETWORK,
2016-06-06 23:22:45 +03:00
XNOR,
2016-05-07 02:25:16 +03:00
BLANK
2015-05-11 23:54:58 +03:00
} LAYER_TYPE;
typedef enum{
2016-01-28 23:30:38 +03:00
SSE, MASKED, SMOOTH
2015-05-11 23:54:58 +03:00
} COST_TYPE;
2015-12-14 22:57:10 +03:00
struct layer{
2015-05-11 23:54:58 +03:00
LAYER_TYPE type;
ACTIVATION activation;
COST_TYPE cost_type;
2015-11-04 06:23:17 +03:00
int batch_normalize;
2016-02-01 02:52:03 +03:00
int shortcut;
2015-05-11 23:54:58 +03:00
int batch;
2015-09-29 00:32:28 +03:00
int forced;
2015-12-14 22:57:10 +03:00
int flipped;
2015-05-11 23:54:58 +03:00
int inputs;
int outputs;
2015-09-17 00:12:10 +03:00
int truths;
2015-05-11 23:54:58 +03:00
int h,w,c;
int out_h, out_w, out_c;
int n;
2016-06-03 01:25:24 +03:00
int max_boxes;
2015-05-11 23:54:58 +03:00
int groups;
int size;
2015-09-01 21:21:01 +03:00
int side;
2015-05-11 23:54:58 +03:00
int stride;
int pad;
2015-09-17 00:12:10 +03:00
int sqrt;
2015-05-11 23:54:58 +03:00
int flip;
2015-12-14 22:57:10 +03:00
int index;
2016-01-28 23:30:38 +03:00
int binary;
2016-05-07 02:25:16 +03:00
int xnor;
2016-01-28 23:30:38 +03:00
int steps;
int hidden;
2016-03-14 09:18:42 +03:00
float dot;
2015-05-11 23:54:58 +03:00
float angle;
2015-10-09 22:50:43 +03:00
float jitter;
2015-05-11 23:54:58 +03:00
float saturation;
float exposure;
2015-11-04 06:23:17 +03:00
float shift;
2015-09-17 00:12:10 +03:00
int softmax;
2015-05-11 23:54:58 +03:00
int classes;
int coords;
int background;
int rescore;
2015-06-10 10:11:41 +03:00
int objectness;
2015-05-11 23:54:58 +03:00
int does_cost;
2015-06-10 10:11:41 +03:00
int joint;
2015-07-14 09:25:08 +03:00
int noadjust;
2015-06-10 10:11:41 +03:00
2015-07-10 01:22:14 +03:00
float alpha;
float beta;
float kappa;
2015-09-22 03:30:32 +03:00
float coord_scale;
float object_scale;
float noobject_scale;
float class_scale;
2015-07-08 10:36:43 +03:00
int dontload;
2015-11-04 06:23:17 +03:00
int dontloadscales;
2015-07-08 10:36:43 +03:00
2016-01-28 23:30:38 +03:00
float temperature;
2015-05-11 23:54:58 +03:00
float probability;
float scale;
2015-09-01 21:21:01 +03:00
2015-05-11 23:54:58 +03:00
int *indexes;
float *rand;
float *cost;
float *filters;
2016-03-16 14:30:48 +03:00
char *cfilters;
2015-05-11 23:54:58 +03:00
float *filter_updates;
2016-01-28 23:30:38 +03:00
float *state;
2016-06-06 23:22:45 +03:00
float *prev_state;
float *forgot_state;
float *forgot_delta;
2016-05-07 02:25:16 +03:00
float *state_delta;
float *concat;
float *concat_delta;
2016-01-28 23:30:38 +03:00
float *binary_filters;
2015-05-11 23:54:58 +03:00
float *biases;
float *bias_updates;
2015-11-04 06:23:17 +03:00
float *scales;
float *scale_updates;
2015-05-11 23:54:58 +03:00
float *weights;
float *weight_updates;
float *col_image;
int * input_layers;
int * input_sizes;
float * delta;
float * output;
2015-07-10 01:22:14 +03:00
float * squared;
float * norms;
2015-05-11 23:54:58 +03:00
2015-11-04 06:23:17 +03:00
float * spatial_mean;
float * mean;
float * variance;
2016-01-28 23:30:38 +03:00
float * mean_delta;
float * variance_delta;
2015-11-04 06:23:17 +03:00
float * rolling_mean;
float * rolling_variance;
2016-01-28 23:30:38 +03:00
float * x;
float * x_norm;
struct layer *input_layer;
struct layer *self_layer;
struct layer *output_layer;
2016-05-07 02:25:16 +03:00
struct layer *input_gate_layer;
struct layer *state_gate_layer;
struct layer *input_save_layer;
struct layer *state_save_layer;
struct layer *input_state_layer;
struct layer *state_state_layer;
struct layer *input_z_layer;
struct layer *state_z_layer;
struct layer *input_r_layer;
struct layer *state_r_layer;
struct layer *input_h_layer;
struct layer *state_h_layer;
2016-06-06 23:22:45 +03:00
float *z_cpu;
float *r_cpu;
float *h_cpu;
2016-06-07 01:48:52 +03:00
float *binary_input;
2016-05-13 21:59:43 +03:00
size_t workspace_size;
2015-05-11 23:54:58 +03:00
#ifdef GPU
2016-05-07 02:25:16 +03:00
float *z_gpu;
float *r_gpu;
float *h_gpu;
2015-05-11 23:54:58 +03:00
int *indexes_gpu;
2016-05-07 02:25:16 +03:00
float * prev_state_gpu;
float * forgot_state_gpu;
float * forgot_delta_gpu;
2016-01-28 23:30:38 +03:00
float * state_gpu;
2016-05-07 02:25:16 +03:00
float * state_delta_gpu;
float * gate_gpu;
float * gate_delta_gpu;
float * save_gpu;
float * save_delta_gpu;
float * concat_gpu;
float * concat_delta_gpu;
2015-05-11 23:54:58 +03:00
float * filters_gpu;
float * filter_updates_gpu;
2016-05-07 02:25:16 +03:00
float *binary_input_gpu;
2016-01-28 23:30:38 +03:00
float *binary_filters_gpu;
2015-11-04 06:23:17 +03:00
float * mean_gpu;
float * variance_gpu;
float * rolling_mean_gpu;
float * rolling_variance_gpu;
float * variance_delta_gpu;
float * mean_delta_gpu;
2015-05-11 23:54:58 +03:00
float * col_image_gpu;
2015-11-04 06:23:17 +03:00
float * x_gpu;
float * x_norm_gpu;
2015-05-11 23:54:58 +03:00
float * weights_gpu;
float * weight_updates_gpu;
2015-11-26 22:48:01 +03:00
float * biases_gpu;
2015-05-11 23:54:58 +03:00
float * bias_updates_gpu;
2015-11-26 22:48:01 +03:00
float * scales_gpu;
2015-11-04 06:23:17 +03:00
float * scale_updates_gpu;
2015-05-11 23:54:58 +03:00
float * output_gpu;
float * delta_gpu;
float * rand_gpu;
2015-07-10 01:22:14 +03:00
float * squared_gpu;
float * norms_gpu;
2016-05-13 21:59:43 +03:00
#ifdef CUDNN
cudnnTensorDescriptor_t srcTensorDesc, dstTensorDesc;
cudnnTensorDescriptor_t dsrcTensorDesc, ddstTensorDesc;
cudnnFilterDescriptor_t filterDesc;
cudnnFilterDescriptor_t dfilterDesc;
cudnnConvolutionDescriptor_t convDesc;
cudnnConvolutionFwdAlgo_t fw_algo;
cudnnConvolutionBwdDataAlgo_t bd_algo;
cudnnConvolutionBwdFilterAlgo_t bf_algo;
#endif
2015-05-11 23:54:58 +03:00
#endif
2015-12-14 22:57:10 +03:00
};
2015-05-11 23:54:58 +03:00
2015-09-01 21:21:01 +03:00
void free_layer(layer);
2015-05-11 23:54:58 +03:00
#endif