提交 2a110af3 编写于 作者: H hedaoyuan

Use Matrix::addBias.

上级 752f29a3
...@@ -155,11 +155,12 @@ void ExpandConvLayer::forward(PassType passType) { ...@@ -155,11 +155,12 @@ void ExpandConvLayer::forward(PassType passType) {
/* add the bias-vector */ /* add the bias-vector */
if (biases_.get()) { if (biases_.get()) {
if (sharedBiases_) { MatrixPtr bias = Matrix::create(biases_->getW()->getData(),
addSharedBias(); 1,
} else { biases_->getW()->getElementCnt(),
addUnsharedBias(); false,
} useGpu_);
output_.value->addBias(*bias, 1.0, sharedBiases_);
} }
/* activation */ /* activation */
...@@ -171,7 +172,13 @@ void ExpandConvLayer::backward(const UpdateCallback &callback) { ...@@ -171,7 +172,13 @@ void ExpandConvLayer::backward(const UpdateCallback &callback) {
MatrixPtr outGrad = getOutputGrad(); MatrixPtr outGrad = getOutputGrad();
if (biases_ && biases_->getWGrad()) { if (biases_ && biases_->getWGrad()) {
bpropBiases(outGrad); // bpropBiases(outGrad);
MatrixPtr bias = Matrix::create(biases_->getWGrad()->getData(),
1,
biases_->getWGrad()->getElementCnt(),
false,
useGpu_);
bias->collectBias(*getOutputGrad(), 1, sharedBiases_);
/* Increasing the number of gradient */ /* Increasing the number of gradient */
biases_->getParameterPtr()->incUpdate(callback); biases_->getParameterPtr()->incUpdate(callback);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册