提交 53946283 编写于 作者: P peterzhang2029

bug fix when using hsigmoid with gpu

上级 cda3a774
...@@ -129,8 +129,7 @@ void HierarchicalSigmoidLayer::forward(PassType passType) { ...@@ -129,8 +129,7 @@ void HierarchicalSigmoidLayer::forward(PassType passType) {
*cpuOutput_, *cpuOutput_,
-1); // scaleSum -1); // scaleSum
preOutput_.value->softrelu(*preOutput_.value); preOutput_.value->softrelu(*preOutput_.value);
MatrixPtr sum = MatrixPtr sum = Matrix::create(batchSize, 1, /* trans= */ false, false);
Matrix::create(batchSize, 1, /* trans= */ false, false);
preOutput_.value->rowSum(*sum); preOutput_.value->rowSum(*sum);
cpuOutput_->add(*sum); cpuOutput_->add(*sum);
if (useGpu_) { if (useGpu_) {
...@@ -164,8 +163,7 @@ void HierarchicalSigmoidLayer::backward(const UpdateCallback& callback) { ...@@ -164,8 +163,7 @@ void HierarchicalSigmoidLayer::backward(const UpdateCallback& callback) {
} else { } else {
cpuBias_ = biases_grad; cpuBias_ = biases_grad;
} }
preOutput_.grad->addByBitCodeBackward( preOutput_.grad->addByBitCodeBackward(numClasses_, *cpuLabel_, *cpuBias_);
numClasses_, *cpuLabel_, *cpuBias_);
if (useGpu) { if (useGpu) {
biases_grad->copyFrom(*cpuBias_); biases_grad->copyFrom(*cpuBias_);
} else { } else {
......
...@@ -89,7 +89,6 @@ protected: ...@@ -89,7 +89,6 @@ protected:
MatrixPtr cpuBias_; MatrixPtr cpuBias_;
MatrixPtr cpuOutput_; MatrixPtr cpuOutput_;
IVectorPtr cpuLabel_; IVectorPtr cpuLabel_;
}; };
} // namespace paddle } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册