forked from btgraham/SparseConvNet-archived
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpatiallySparseBatchInterface.h
More file actions
40 lines (38 loc) · 1.81 KB
/
SpatiallySparseBatchInterface.h
File metadata and controls
40 lines (38 loc) · 1.81 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
#pragma once
#include <vector>
#include "SparseGrid.h"
#include "vectorCUDA.h"
//This is a subset of the whole interface.
//It contains the larger vectors that can mostly stay on the GPU
class SpatiallySparseBatchSubInterface {
public:
vectorCUDA<float> features; // In the input layer, this is configured during preprocessing
vectorCUDA<float> dfeatures; // For the backwards/backpropagation pass
vectorCUDA<int> poolingChoices;
void reset() {
features.resize(0);
dfeatures.resize(0);
poolingChoices.resize(0);
}
};
class SpatiallySparseBatchInterface {
public:
SpatiallySparseBatchSubInterface* sub;
int nFeatures; // Features per spatial location
// Not dropped out features per spatial location
vectorCUDA<int> featuresPresent; // For dropout rng.NchooseM(nFeatures,featuresPresent.size());
int nSpatialSites; // Total active spatial locations within the
int spatialSize; // spatialSize x spatialSize grid
// batchSize x spatialSize x spatialSize
// possible locations.
bool backpropErrors; //Calculate dfeatures? (false until after the first NiN layer)
std::vector<SparseGrid> grids; // batchSize vectors of maps storing info on grids of size spatialSize x spatialSize
// Store locations of nSpatialSites in the
// spatialSize x spatialSize grids
// -1 entry corresponds to null vectors in needed
// Below used internally for convolution/pooling operation:
vectorCUDA<int> rules;
SpatiallySparseBatchInterface();
void summary();
void reset();
};