-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConvLayer.cuh
38 lines (35 loc) · 1.08 KB
/
ConvLayer.cuh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef ALEXNET_CONVOLUTIONAL_CUH
#define ALEXNET_CONVOLUTIONAL_CUH
using namespace std;
#include "Layer.cuh"
#include <memory>
#include <random>
#include <cuda_runtime.h>
class ConvLayer: public Layer{
public:
ConvLayer(int input_size, int channels, int kernel_size, int kernel_num, int stride, bool pad, Act func);
~ConvLayer();
int getInputSize();
int getKernelSize();
int getChannel();
int getOutputSize();
int getOutputChannel();
float *forward(float *image) override;
float *backpropagation(float* cost, float* back_neurons) override;
void applyGradient(float lr) override;
int getNeurons() override;
int getNumBackNeurons() override;
private:
int input_size; //lato dell'immagine
int channels; //profondità
int kernel_size; //lato del kernel
int kernel_num; //numero di kernel
int stride;
int pad;
int output_size; // lato dell'output
int output_len; //output_size*output_size*kernel_num
float *current_bias_derivative;
float *current_weights_derivative;
float *prev_layer_derivative;
};
#endif //ALEXNET_CONVOLUTIONAL_CUH