-
Notifications
You must be signed in to change notification settings - Fork 2
/
ReallyConvolutionalLayer.h
47 lines (45 loc) · 1.71 KB
/
ReallyConvolutionalLayer.h
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
39
40
41
42
43
44
45
46
47
#pragma once
#include "SpatiallySparseLayer.h"
class ReallyConvolutionalLayer : public SpatiallySparseLayer {
private:
int fs;
RNG rng;
float leaky;
public:
int inSpatialSize;
int outSpatialSize;
int filterSize;
int filterStride;
int dimension;
ActivationFunction fn;
int nFeaturesIn;
int nFeaturesOut;
float dropout;
int minActiveInputs;
vectorCUDA<float> W; // Weights
vectorCUDA<float> MW; // momentum
vectorCUDA<float> w; // shrunk versions
vectorCUDA<float> dw; // For backprop
vectorCUDA<float> B; // Weights
vectorCUDA<float> MB; // momentum
vectorCUDA<float> b; // shrunk versions
vectorCUDA<float> db; // For backprop
ReallyConvolutionalLayer(cudaMemStream &memStream, int nFeaturesIn,
int nFeaturesOut, int filterSize, int filterStride,
int dimension, ActivationFunction fn, float dropout,
int minActiveInputs = 1, float poolingToFollow = 1);
void preprocess(SpatiallySparseBatch &batch,
SpatiallySparseBatchInterface &input,
SpatiallySparseBatchInterface &output);
void forwards(SpatiallySparseBatch &batch,
SpatiallySparseBatchInterface &input,
SpatiallySparseBatchInterface &output);
void backwards(SpatiallySparseBatch &batch,
SpatiallySparseBatchInterface &input,
SpatiallySparseBatchInterface &output, float learningRate,
float momentum);
void scaleWeights(SpatiallySparseBatchInterface &input,
SpatiallySparseBatchInterface &output,
float &scalingUnderneath, bool topLayer);
int calculateInputSpatialSize(int outputSpatialSize);
};