MCPcopy Create free account
hub / github.com/audeering/opensmile / forward

Method forward

src/rnn/rnn.cpp:68–137  ·  view source on GitHub ↗

feed data through the cell and compute the cell output (return value) note: for an lstm block with nCells > 1, the number of output values will be > 1... how to handle this??

Source from the content-addressed store, hash-verified

66// feed data through the cell and compute the cell output (return value)
67// note: for an lstm block with nCells > 1, the number of output values will be > 1... how to handle this??
68const FLOAT_NN * cNnLSTMcell::forward(const FLOAT_NN *x, long *N)
69{
70 // x[0] IG input
71 // x[1] FG input
72 // x[2] cell input to cell 1
73 //( x[3] cell input to cell 2...)
74 //( x[4] cell input to cell 3...)
75 // ...
76 // x[N] OG input
77
78 FLOAT_NN actIG, actFG, actOG;
79
80 if (nCells == 1) { // quick version for one cell per block
81
82 // input Gate
83 actIG = transferGate->f( x[0] + (*sc)*peep[0] );
84 // forget Gate
85 actFG = transferGate->f( x[1] + (*sc)*peep[1] );
86 // cell
87 *sc = actIG * *cNnNNcell::forward(x+2) + (*sc)*actFG;
88 // output Gate
89 actOG = transferGate->f( x[3] + (*sc)*peep[2] );
90 // cell output
91
92 cellOutput = actOG * transferOut->f( *sc );
93 //XX//fprintf(stderr,"pg: %f --> cellOutput %f actOG %f ag: %f\n",*sc,cellOutput,actOG,transferOut->f( *sc ));
94
95 if (N!=NULL) *N=1;
96 return &cellOutput;
97
98 } else { // long version
99 long i;
100 FLOAT_NN sum=0.0;
101
102 // input Gate
103 for (i=0; i<nCells; i++) { // TODO: check the order of the peephole weights
104 sum += (sc[i])*peep[i];
105 }
106 actIG = transferGate->f( x[0] + sum );
107
108 // forget Gate // TODO: add multi-dim. forget gate acts...? "num_seq_dims"
109 sum = 0.0;
110 for (i=0; i<nCells; i++) { // TODO: check the order of the peephole weights
111 sum += (sc[i])*peep[i+nCells];
112 }
113 actFG = transferGate->f( x[1] + sum );
114
115 // cell
116 for (i=0; i<nCells; i++) {
117 sc[i] = actIG * *cNnNNcell::forward(x+2+i) + (sc[i])*actFG;
118 // TODO: add multi-dim. forget gate acts...? "num_seq_dims"
119 }
120
121 // output Gate
122 sum = 0.0;
123 for (i=0; i<nCells; i++) { // TODO: check the order of the peephole weights
124 sum += (sc[i])*peep[i+2*nCells];
125 }

Callers 2

myTickMethod · 0.45
myTickMethod · 0.45

Calls 7

isReverseMethod · 0.80
outputAvailableMethod · 0.80
getNContextMethod · 0.80
resetLayerMethod · 0.80
fMethod · 0.45
getOutputMethod · 0.45
getOutputSizeMethod · 0.45

Tested by

no test coverage detected