blob: d1b670d71aa75ca14e31d9cca109c6d83746a52d (
plain)
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
87
88
89
|
#ifndef NEURAL_COLUMN_H
#define NEURAL_COLUMN_H
#include "neural/container.h"
namespace Neural
{
template<typename sigtype>
class Column : public Container<sigtype>
{
public:
Column()
{
}
virtual ~Column()
{
}
virtual void finalize( int iNumInputs )
{
iInputs = iNumInputs;
iWeights = 0;
iBiases = 0;
int iNextInputs = iInputs;
for( typename Container<sigtype>::NodeList::iterator i =
Container<sigtype>::getNodeList().begin(); i; i++ )
{
(*i)->finalize( iNextInputs );
iNextInputs = (*i)->getNumOutputs();
if( (i+1) )
{
lBuffer.append( new sigtype[iNextInputs] );
}
iWeights += (*i)->getNumWeights();
iBiases += (*i)->getNumBiases();
}
}
virtual void process( sigtype *aInput, sigtype *aOutput )
{
typename BufferList::iterator iBuf = lBuffer.begin();
sigtype *pBuffer = aInput;
sigtype *pNextBuffer = *iBuf;
for( typename Container<sigtype>::NodeList::iterator i =
Container<sigtype>::getNodeList().begin(); i; i++ )
{
(*i)->process( pBuffer, pNextBuffer );
pBuffer = pNextBuffer;
if( iBuf )
iBuf++;
if( iBuf )
pNextBuffer = *iBuf;
else
pNextBuffer = aOutput;
}
}
virtual int getNumInputs() const
{
return iInputs;
}
virtual int getNumOutputs() const
{
return Container<sigtype>::getNodeList().last()->getNumOutputs();
}
virtual int getNumWeights() const
{
return iWeights;
}
virtual int getNumBiases() const
{
return iBiases;
}
private:
int iInputs;
int iWeights;
int iBiases;
typedef Bu::List<sigtype *> BufferList;
BufferList lBuffer;
};
};
#endif
|