Skip to content

Add ScaleSubRegion Layer.#5488

Merged
pkuyym merged 5 commits intoPaddlePaddle:developfrom
pkuyym:fix-5417
Nov 9, 2017
Merged

Add ScaleSubRegion Layer.#5488
pkuyym merged 5 commits intoPaddlePaddle:developfrom
pkuyym:fix-5417

Conversation

@pkuyym
Copy link
Contributor

@pkuyym pkuyym commented Nov 8, 2017

Resolves #5416

* input_1: Indices value to specify the location an shape of the
* region.
*/
class MulValueLayer : public Layer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MulValueLayer 会不会让人产生误解?ScaleLayer ? SubScaleLayer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to ScaleSubRegionLayer.

<< " channels=" << channels << " imgSizeH=" << imgSizeH
<< " imgSizeW=" << imgSizeW;

for (bool test_grad : {false}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_grad -> testGrad, 和前边变量保持一致?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<< " channels=" << channels << " imgSizeH=" << imgSizeH
<< " imgSizeW=" << imgSizeW;

for (bool test_grad : {false}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么不测试Grad呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

if (initArgsCallback_ != nullptr) {
initArgsCallback_(*func1Inputs_[i], i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果input[1]的初始化依赖input[0],怎么办?把initArgsCallback_放到循环外,整个func1Inputs_作为参数,会不会更灵活些?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callback的场景比较有限,如果出现你说的情况,可以到时再考虑扩展

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.


for (size_t i = 0; i < numSamples; ++i) {
size_t offset = i * 6;
data[offset] = firstHalf ? 1 : (int)channels / 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要(int) 吧?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

channelsNum_ = imgV->getWidth() / spatialSize;
shape_ = TensorShape({batchSize, channelsNum_, imgH_, imgW_});

resetOutput(batchSize, imgV->getWidth());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是应该设置下outputFrameHeightFrameWidth? 下个layer有可能用到。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@qingqing01 qingqing01 changed the title Add MulValueLayer Nov 9, 2017
Copy link
Contributor

@qingqing01 qingqing01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paddle/gserver/layers/MulValueLayer.h
paddle/gserver/layers/MulValueLayer.cpp

没有删除。

namespace paddle {

template <>
void MulValue<DEVICE_TYPE_CPU>(real* outputs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MulValue -> ScaleSubRegion ?

for (size_t numSamples : {5, 32}) {
for (size_t channels : {5, 5, 32}) {
for (size_t imgSizeH : {5, 33, 100}) {
for (size_t imgSizeW : {5, 32, 96}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

减少channels,imgSizeH,imgSizeW遍历吧, 减少for循环的次数,减少单测时间。

Copy link
Contributor

@wanghaoshuang wanghaoshuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@pkuyym pkuyym merged commit 3b32eb9 into PaddlePaddle:develop Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants