CorTeX Core ABI 7
ToolTech Software · C++ library reference
Loading...
Searching...
No Matches
ctxCortexLayer.h
Go to the documentation of this file.
1//*****************************************************************************
2// File : ctxCortexLayer.h
3// Description : A layer of neurons in the brain
4// Author : Anders Modén
5// Product : CorTeX 2.0.1
6//
7// Copyright © 2015- Anders Modén, Sweden
8//
9// NOTE: CorTeX is a software development kit (SDK)
10// for neural networks and genetic programming.
11// Licensed by Anders Modén.
12//
13//
14// Revision History...
15//
16// Who Date Description
17//
18// AMO 260828 Tracked semantic Convolution parameter ranges (2.0.2)
19// AMO 150708 Created file (1.0.0)
20//
21//******************************************************************************
22#ifndef __CTX_CORTEX_LAYER_H__
23#define __CTX_CORTEX_LAYER_H__
24
25#include "ctxNeuron.h"
26#include "ctxContext.h"
27
28// -------------------------------- ctxCortexLayer -----------------------------------
29
37
39{
40public:
41
42 ctxIndexControl(gzUInt32 features_,
43 gzUInt32 width_,
44 gzUInt32 height_,
45 gzUInt32 depth_,
46
47 gzUInt32 width_stride_ = CTX_USE_DEFAULT_VALUE,
48 gzUInt32 height_stride_ = CTX_USE_DEFAULT_VALUE,
49 gzUInt32 depth_stride_ = CTX_USE_DEFAULT_VALUE,
50
51 gzUInt32 padding_left_ = CTX_USE_DEFAULT_VALUE,
52 gzUInt32 padding_right_ = CTX_USE_DEFAULT_VALUE,
53 gzUInt32 padding_top_ = CTX_USE_DEFAULT_VALUE,
54 gzUInt32 padding_bottom_ = CTX_USE_DEFAULT_VALUE,
55 gzUInt32 padding_front_ = CTX_USE_DEFAULT_VALUE,
56 gzUInt32 padding_back_ = CTX_USE_DEFAULT_VALUE,
57
58 gzUInt32 width_steps_ = CTX_USE_DEFAULT_VALUE,
59 gzUInt32 height_steps_ = CTX_USE_DEFAULT_VALUE,
60 gzUInt32 depth_steps_ = CTX_USE_DEFAULT_VALUE):features(features_),width(width_),height(height_),depth(depth_),width_stride(width_stride_),height_stride(height_stride_),depth_stride(depth_stride_),padding_left(padding_left_),padding_right(padding_right_),padding_top(padding_top_),padding_bottom(padding_bottom_),padding_front(padding_front_),padding_back(padding_back_), width_steps(width_steps_), height_steps(height_steps_), depth_steps(depth_steps_) {}
61
62 gzVoid updateDefaults(gzUInt32 default_width_stride,gzUInt32 default_height_stride,gzUInt32 default_depth_stride,gzUInt32 block_width,gzUInt32 block_height, gzUInt32 block_depth)
63 {
64 if (!width_stride)
65 width_stride = default_width_stride;
66
67 if (!height_stride)
68 height_stride = default_height_stride;
69
70 if (!depth_stride)
71 depth_stride = default_depth_stride;
72
73 if (!width_steps && (width + padding_left + padding_right>=block_width))
75
76 if (!height_steps && (height + padding_top + padding_bottom>=block_height))
77 height_steps = (height + padding_top + padding_bottom - block_height) / height_stride + 1;
78
79 if (!depth_steps && (depth + padding_front + padding_back>= block_depth))
80 depth_steps = (depth + padding_front + padding_back - block_depth) / depth_stride + 1;
81 }
82
83 // Public properties of index control
84
85 gzUInt32 features;
86
87 gzUInt32 width;
88 gzUInt32 height;
89 gzUInt32 depth;
90
91 gzUInt32 width_steps;
92 gzUInt32 height_steps;
93 gzUInt32 depth_steps;
94
95 gzUInt32 width_stride;
96 gzUInt32 height_stride;
97 gzUInt32 depth_stride;
98
99 gzUInt32 padding_left;
101 gzUInt32 padding_top;
104 gzUInt32 padding_back;
105
106};
107
108class ctxCortexLayer : public gzReference
109{
110public:
111
112 GZ_DECLARE_TYPE_INTERFACE_EXPORT(CTX_EXPORT);
113
116
117 CTX_EXPORT gzVoid addLayerNeurons(gzUInt32 layerNeurons,ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT,gzUInt32 synapses=0,ctxContext *shared=NULL);
118 CTX_EXPORT gzVoid addConvolutionNeurons(ctxIndexControl source, ctxIndexControl filter, ctxContext *context, gzUInt32 maxNumberOfFeaturesDebug = 0,ctxNeuronType type = CTX_NEURON_TYPE_DEFAULT, gzBool sharedBias = TRUE,gzUInt32 source_offset=0);
119 CTX_EXPORT gzVoid addMappedConvolutionSynapses(gzUInt32 sourceFeatureIndex,
120 gzUInt32 sourceFeatureCount, gzUInt32 destinationFeatureIndex,
121 gzUInt32 destinationFeatureCount, gzUInt32 sourceWidth, gzUInt32 sourceHeight,
122 gzUInt32 sourceDepth, gzUInt32 destinationWidth, gzUInt32 destinationHeight,
123 gzUInt32 destinationDepth, gzUInt32 destinationOriginX,
124 gzUInt32 destinationOriginY, gzUInt32 destinationOriginZ,
125 gzUInt32 regionWidth, gzUInt32 regionHeight, gzUInt32 regionDepth,
126 gzInt32 sourceOriginX, gzInt32 sourceOriginY,
127 gzInt32 sourceOriginZ, gzUInt32 kernelWidth, gzUInt32 kernelHeight,
128 gzUInt32 kernelDepth, gzUInt32 strideX, gzUInt32 strideY, gzUInt32 strideZ,
129 gzUInt32 paddingLeft, gzUInt32 paddingTop, gzUInt32 paddingFront,
130 gzUInt32 dilationX, gzUInt32 dilationY, gzUInt32 dilationZ,
131 ctxCortexLayer* sourceLayer, ctxInput* input, ctxContext* context,
132 gzUInt32 parameterBaseIndex, gzUInt32 mappingOccurrenceID,
133 gzUInt32 parameterGroupID);
134 CTX_EXPORT gzVoid addPoolingNeurons(ctxIndexControl source, ctxIndexControl filter, ctxContext *context=NULL, gzUInt32 maxNumberOfFeaturesDebug = 0,ctxNeuronType type = CTX_NEURON_TYPE_MAX, gzUInt32 source_offset=0);
135
136 CTX_EXPORT gzVoid setFeatureStart(ctxContext *context, gzUInt32 id, gzUInt32 features, gzUInt32 width, gzUInt32 height, gzUInt32 depth);
137
138 CTX_EXPORT gzVoid setDropConnection(gzBool on);
139
142
145
146 // Get Access
148 CTX_EXPORT ctxNeuron * getNeuron(gzUInt32 neuronIndex);
150 CTX_EXPORT gzRefList<ctxCortexLayer>& getSubInputLayerList() { return m_subInputLayers; }
151 CTX_EXPORT gzRefList<ctxCortexLayer>& getSubHiddenLayerList() { return m_subHiddenLayers; }
152 CTX_EXPORT gzRefList<ctxCortexLayer>& getSubOutputLayerList() { return m_subOutputLayers; }
153
157
160
161 CTX_EXPORT gzVoid setDebugFlags(ctxContext *context,ctxDebugFlags flags,gzUInt32 layerID,gzUInt32 maxCount=5,gzBool onSynapses=FALSE,gzUInt32 maxFeature=CTX_UNDEFINED_INDEX);
162
164
166 CTX_EXPORT virtual gzReference* clone() const;
167
168protected:
169
170 friend class ctxCortex;
171
172 gzDynamicArray<ctxNeuronPtr> m_layerNeurons;
173
174 gzRefList<ctxCortexLayer> m_subInputLayers;
175 gzRefList<ctxCortexLayer> m_subHiddenLayers;
176 gzRefList<ctxCortexLayer> m_subOutputLayers;
177};
178
179GZ_DECLARE_REFPTR(ctxCortexLayer);
180
181// --------------------------------------------------------------------------
182
184{
185public:
186
187 CTX_EXPORT gzVoid addNeuronLayers(gzUInt32 layers,gzUInt32 layerNeurons,ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT);
188 CTX_EXPORT ctxCortexLayer* addConvolutionLayer(ctxIndexControl source, ctxIndexControl filter,ctxContext *context, gzUInt32 maxNumberOfFeaturesDebug=0 ,ctxNeuronType type = CTX_NEURON_TYPE_DEFAULT, gzBool sharedBias = TRUE);
189 CTX_EXPORT ctxCortexLayer* addPoolingLayer(ctxIndexControl source, ctxIndexControl filter, ctxContext *context=NULL, gzUInt32 maxNumberOfFeaturesDebug = 0,ctxNeuronType type = CTX_NEURON_TYPE_MAX);
190
193
194 CTX_EXPORT gzVoid setDropConnection(gzBool on);
195
196 CTX_EXPORT ctxCortexLayer *getLayer(gzUInt32 layerIndex,gzBool indexFromLeft=TRUE);
197 CTX_EXPORT gzRefList<ctxCortexLayer>& getLayerList() { return m_layerList; }
198
199protected:
200
201 gzRefList<ctxCortexLayer> m_layerList;
202
203};
204
205#endif //__CTX_CORTEX_LAYER_H__
gzVoid addNeuron(ctxNeuron *neuron)
virtual gzReference * clone() const
Built in clone.
gzUInt32 getNeuronCount()
gzRefList< ctxCortexLayer > & getSubInputLayerList()
gzVoid connectInput(ctxCortexLayer *input)
ctxNeuron * getNeuron(gzUInt32 neuronIndex)
gzVoid removeSubLayer(ctxCortexLayer *layer)
gzRefList< ctxCortexLayer > & getSubHiddenLayerList()
gzRefList< ctxCortexLayer > m_subInputLayers
gzVoid connectOutput(ctxCortexLayer *output)
gzVoid addLayerNeurons(gzUInt32 layerNeurons, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT, gzUInt32 synapses=0, ctxContext *shared=NULL)
gzRefList< ctxCortexLayer > m_subHiddenLayers
gzVoid addConvolutionNeurons(ctxIndexControl source, ctxIndexControl filter, ctxContext *context, gzUInt32 maxNumberOfFeaturesDebug=0, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT, gzBool sharedBias=TRUE, gzUInt32 source_offset=0)
gzVoid addSubLayer(ctxCortexLayer *layer, ctxLayerType type=CTX_IN_OUT_LAYER)
gzVoid setDebugFlags(ctxContext *context, ctxDebugFlags flags, gzUInt32 layerID, gzUInt32 maxCount=5, gzBool onSynapses=FALSE, gzUInt32 maxFeature=CTX_UNDEFINED_INDEX)
gzVoid addMappedConvolutionSynapses(gzUInt32 sourceFeatureIndex, gzUInt32 sourceFeatureCount, gzUInt32 destinationFeatureIndex, gzUInt32 destinationFeatureCount, gzUInt32 sourceWidth, gzUInt32 sourceHeight, gzUInt32 sourceDepth, gzUInt32 destinationWidth, gzUInt32 destinationHeight, gzUInt32 destinationDepth, gzUInt32 destinationOriginX, gzUInt32 destinationOriginY, gzUInt32 destinationOriginZ, gzUInt32 regionWidth, gzUInt32 regionHeight, gzUInt32 regionDepth, gzInt32 sourceOriginX, gzInt32 sourceOriginY, gzInt32 sourceOriginZ, gzUInt32 kernelWidth, gzUInt32 kernelHeight, gzUInt32 kernelDepth, gzUInt32 strideX, gzUInt32 strideY, gzUInt32 strideZ, gzUInt32 paddingLeft, gzUInt32 paddingTop, gzUInt32 paddingFront, gzUInt32 dilationX, gzUInt32 dilationY, gzUInt32 dilationZ, ctxCortexLayer *sourceLayer, ctxInput *input, ctxContext *context, gzUInt32 parameterBaseIndex, gzUInt32 mappingOccurrenceID, gzUInt32 parameterGroupID)
gzDynamicArray< ctxNeuronPtr > m_layerNeurons
gzVoid connectInput(ctxNeuron *input)
virtual ~ctxCortexLayer()
gzRefList< ctxCortexLayer > & getSubOutputLayerList()
gzVoid connectInput(ctxInput *input)
friend class ctxCortex
gzVoid setFeatureStart(ctxContext *context, gzUInt32 id, gzUInt32 features, gzUInt32 width, gzUInt32 height, gzUInt32 depth)
gzVoid setDropConnection(gzBool on)
gzVoid addPoolingNeurons(ctxIndexControl source, ctxIndexControl filter, ctxContext *context=NULL, gzUInt32 maxNumberOfFeaturesDebug=0, ctxNeuronType type=CTX_NEURON_TYPE_MAX, gzUInt32 source_offset=0)
gzVoid removeNeuron(ctxNeuron *neuron)
ctxCortexLayer * getSubLayer(gzUInt32 layerIndex, ctxLayerType type=CTX_INPUT_LAYER)
gzVoid debugConnections(gzUInt32 index=CTX_UNDEFINED_INDEX)
gzRefList< ctxCortexLayer > m_subOutputLayers
gzVoid connectOutput(ctxNeuron *output)
gzVoid addLayer(ctxCortexLayer *layer)
ctxCortexLayer * addConvolutionLayer(ctxIndexControl source, ctxIndexControl filter, ctxContext *context, gzUInt32 maxNumberOfFeaturesDebug=0, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT, gzBool sharedBias=TRUE)
gzRefList< ctxCortexLayer > & getLayerList()
ctxCortexLayer * addPoolingLayer(ctxIndexControl source, ctxIndexControl filter, ctxContext *context=NULL, gzUInt32 maxNumberOfFeaturesDebug=0, ctxNeuronType type=CTX_NEURON_TYPE_MAX)
gzVoid setDropConnection(gzBool on)
ctxCortexLayer * getLayer(gzUInt32 layerIndex, gzBool indexFromLeft=TRUE)
gzRefList< ctxCortexLayer > m_layerList
gzVoid addNeuronLayers(gzUInt32 layers, gzUInt32 layerNeurons, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
gzVoid removeLayer(ctxCortexLayer *layer)
gzUInt32 depth_stride
gzVoid updateDefaults(gzUInt32 default_width_stride, gzUInt32 default_height_stride, gzUInt32 default_depth_stride, gzUInt32 block_width, gzUInt32 block_height, gzUInt32 block_depth)
gzUInt32 height_stride
gzUInt32 height_steps
gzUInt32 width_stride
gzUInt32 padding_bottom
gzUInt32 padding_left
ctxIndexControl(gzUInt32 features_, gzUInt32 width_, gzUInt32 height_, gzUInt32 depth_, gzUInt32 width_stride_=CTX_USE_DEFAULT_VALUE, gzUInt32 height_stride_=CTX_USE_DEFAULT_VALUE, gzUInt32 depth_stride_=CTX_USE_DEFAULT_VALUE, gzUInt32 padding_left_=CTX_USE_DEFAULT_VALUE, gzUInt32 padding_right_=CTX_USE_DEFAULT_VALUE, gzUInt32 padding_top_=CTX_USE_DEFAULT_VALUE, gzUInt32 padding_bottom_=CTX_USE_DEFAULT_VALUE, gzUInt32 padding_front_=CTX_USE_DEFAULT_VALUE, gzUInt32 padding_back_=CTX_USE_DEFAULT_VALUE, gzUInt32 width_steps_=CTX_USE_DEFAULT_VALUE, gzUInt32 height_steps_=CTX_USE_DEFAULT_VALUE, gzUInt32 depth_steps_=CTX_USE_DEFAULT_VALUE)
#define CTX_EXPORT
Definition ctxBase.h:68
ctxNeuronType
@ CTX_NEURON_TYPE_MAX
@ CTX_NEURON_TYPE_DEFAULT
ctxLayerType
@ CTX_OUTPUT_LAYER
@ CTX_HIDDEN_LAYER
@ CTX_IN_OUT_LAYER
@ CTX_INPUT_LAYER
const gzUInt8 CTX_USE_DEFAULT_VALUE
Definition ctxTypes.h:36
ctxDebugFlags
Definition ctxTypes.h:47
const gzUInt32 CTX_UNDEFINED_INDEX
Definition ctxTypes.h:35