forked from btgraham/SparseConvNet-archived
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaxPoolingLayer.h
More file actions
86 lines (80 loc) · 2.74 KB
/
MaxPoolingLayer.h
File metadata and controls
86 lines (80 loc) · 2.74 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#include <iostream>
#include "SpatiallySparseLayer.h"
#include "Rng.h"
void maxPool(float* g1, float* g2, int* rules, int count, int sd, int nOut, int* d_choice);
void maxPoolBackProp(float* d1, float* d2, int count, int nOut, int* d_choice);
//TODO: Refactor the different pooling classes somehow
class MaxPoolingLayer : public SpatiallySparseLayer {
public:
int inSpatialSize;
int outSpatialSize;
int poolSize;
int poolStride;
int dimension;
int sd;
MaxPoolingLayer(int poolSize, int poolStride, int dimension);
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);
int calculateInputSpatialSize(int outputSpatialSize);
};
class PseudorandomOverlappingFractionalMaxPoolingLayer : public SpatiallySparseLayer {
int sd;
public:
int inSpatialSize;
int outSpatialSize;
float fmpShrink;
int poolSize;
int dimension;
RNG rng;
PseudorandomOverlappingFractionalMaxPoolingLayer(int poolSize, float fmpShrink, int dimension);
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);
int calculateInputSpatialSize(int outputSpatialSize);
};
class RandomOverlappingFractionalMaxPoolingLayer : public SpatiallySparseLayer {
int sd;
public:
int inSpatialSize;
int outSpatialSize;
float fmpShrink;
int poolSize;
int dimension;
RNG rng;
RandomOverlappingFractionalMaxPoolingLayer(int poolSize, float fmpShrink, int dimension);
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);
int calculateInputSpatialSize(int outputSpatialSize);
};