@@ -215,12 +215,12 @@ void RecurrentLayer::forwardSequence(int batchSize,
215215void RecurrentLayer::forwardOneSequence (int start, int length) {
216216 if (!reversed_) {
217217 if (prevOutput_) {
218- frameOutput_[start].value ->mul (prevOutput_, weight_->getW (), 1 , 1 );
218+ frameOutput_[start].value ->mul (* prevOutput_, * weight_->getW (), 1 , 1 );
219219 }
220220 activation_->forward (frameOutput_[start]);
221221 for (int i = 1 ; i < length; ++i) {
222222 frameOutput_[start + i].value ->mul (
223- frameOutput_[start + i - 1 ].value , weight_->getW (), 1 , 1 );
223+ * frameOutput_[start + i - 1 ].value , * weight_->getW (), 1 , 1 );
224224 activation_->forward (frameOutput_[start + i]);
225225 }
226226 if (prevOutput_) {
@@ -230,7 +230,7 @@ void RecurrentLayer::forwardOneSequence(int start, int length) {
230230 activation_->forward (frameOutput_[start + length - 1 ]);
231231 for (int i = length - 2 ; i >= 0 ; --i) {
232232 frameOutput_[start + i].value ->mul (
233- frameOutput_[start + i + 1 ].value , weight_->getW (), 1 , 1 );
233+ * frameOutput_[start + i + 1 ].value , * weight_->getW (), 1 , 1 );
234234 activation_->forward (frameOutput_[start + i]);
235235 }
236236 }
@@ -282,27 +282,27 @@ void RecurrentLayer::backwardOneSequence(int start, int length) {
282282 for (int i = length - 1 ; i > 0 ; --i) {
283283 activation_->backward (frameOutput_[start + i]);
284284 frameOutput_[start + i - 1 ].grad ->mul (
285- frameOutput_[start + i].grad , weightT, 1 , 1 );
285+ * frameOutput_[start + i].grad , * weightT, 1 , 1 );
286286 }
287287 activation_->backward (frameOutput_[start]);
288288 if (weight_->getWGrad ()) {
289289 weight_->getWGrad ()->mul (
290- output_.value ->subMatrix (start, length - 1 )->getTranspose (),
291- output_.grad ->subMatrix (start + 1 , length - 1 ),
290+ * output_.value ->subMatrix (start, length - 1 )->getTranspose (),
291+ * output_.grad ->subMatrix (start + 1 , length - 1 ),
292292 1 ,
293293 1 );
294294 }
295295 } else {
296296 for (int i = 0 ; i < length - 1 ; ++i) {
297297 activation_->backward (frameOutput_[start + i]);
298298 frameOutput_[start + i + 1 ].grad ->mul (
299- frameOutput_[start + i].grad , weightT, 1 , 1 );
299+ * frameOutput_[start + i].grad , * weightT, 1 , 1 );
300300 }
301301 activation_->backward (frameOutput_[start + length - 1 ]);
302302 if (weight_->getWGrad ()) {
303303 weight_->getWGrad ()->mul (
304- output_.value ->subMatrix (start + 1 , length - 1 )->getTranspose (),
305- output_.grad ->subMatrix (start, length - 1 ),
304+ * output_.value ->subMatrix (start + 1 , length - 1 )->getTranspose (),
305+ * output_.grad ->subMatrix (start, length - 1 ),
306306 1 ,
307307 1 );
308308 }
@@ -329,7 +329,7 @@ void RecurrentLayer::forwardBatch(int batchSize,
329329 if (n != 0 ) {
330330 MatrixPtr batch1 =
331331 batchValue_->getBatchValue (n - 1 , batch2->getHeight ());
332- batch2->mul (batch1, weight_->getW (), 1 , 1 );
332+ batch2->mul (* batch1, * weight_->getW (), 1 , 1 );
333333 }
334334 Argument arg;
335335 arg.value = batch2;
@@ -367,14 +367,14 @@ void RecurrentLayer::backwardBatch(int batchSize,
367367
368368 if (n != 0 ) {
369369 batch1 = batchGrad_->getBatchValue (n - 1 , batch2->getHeight ());
370- batch1->mul (batch2, weightT, 1 , 1 );
370+ batch1->mul (* batch2, * weightT, 1 , 1 );
371371 }
372372
373373 if (backwardByBatch && weight_->getWGrad ()) {
374374 if (n != 0 ) {
375375 /* backward weight */
376376 batch1 = batchValue_->getBatchValue (n - 1 , batch2->getHeight ());
377- weight_->getWGrad ()->mul (batch1->getTranspose (), batch2, 1 , 1 );
377+ weight_->getWGrad ()->mul (* batch1->getTranspose (), * batch2, 1 , 1 );
378378 }
379379 }
380380 }
@@ -389,14 +389,14 @@ void RecurrentLayer::backwardBatch(int batchSize,
389389 int len = starts[seq + 1 ] - starts[seq];
390390 if (!reversed_) {
391391 weight_->getWGrad ()->mul (
392- output_.value ->subMatrix (starts[seq], len - 1 )->getTranspose (),
393- output_.grad ->subMatrix (starts[seq] + 1 , len - 1 ),
392+ * output_.value ->subMatrix (starts[seq], len - 1 )->getTranspose (),
393+ * output_.grad ->subMatrix (starts[seq] + 1 , len - 1 ),
394394 1 ,
395395 1 );
396396 } else {
397397 weight_->getWGrad ()->mul (
398- output_.value ->subMatrix (starts[seq] + 1 , len - 1 )->getTranspose (),
399- output_.grad ->subMatrix (starts[seq], len - 1 ),
398+ * output_.value ->subMatrix (starts[seq] + 1 , len - 1 )->getTranspose (),
399+ * output_.grad ->subMatrix (starts[seq], len - 1 ),
400400 1 ,
401401 1 );
402402 }
0 commit comments