Commit a36ebaec authored by Dmitry Kurtaev's avatar Dmitry Kurtaev

PReLU layer for multidimensional input

parent cca99bf8
...@@ -80,20 +80,19 @@ public: ...@@ -80,20 +80,19 @@ public:
void operator()(const Range &r) const void operator()(const Range &r) const
{ {
int nstripes = nstripes_, nsamples, outCn; int nstripes = nstripes_, nsamples = 1, outCn = 1;
size_t planeSize; size_t planeSize = 1;
if( src_->dims == 4 ) if (src_->dims > 1)
{ {
nsamples = src_->size[0]; nsamples = src_->size[0];
outCn = src_->size[1]; outCn = src_->size[1];
planeSize = (size_t)src_->size[2]*src_->size[3];
} }
else else
{ outCn = src_->size[0];
nsamples = outCn = 1;
planeSize = (size_t)src_->total(); for (int i = 2; i < src_->dims; ++i)
} planeSize *= src_->size[i];
size_t stripeSize = (planeSize + nstripes - 1)/nstripes; size_t stripeSize = (planeSize + nstripes - 1)/nstripes;
size_t stripeStart = r.start*stripeSize; size_t stripeStart = r.start*stripeSize;
......
...@@ -242,9 +242,8 @@ public: ...@@ -242,9 +242,8 @@ public:
} }
} }
// TODO: check whether this is correct in the case of ChannelsPReLU.
if(activ) if(activ)
activ->forwardSlice(dptr, dptr, nw, 0, 0, 1); activ->forwardSlice(dptr, dptr, 1, 1, delta, delta + nw);
ofs += nw; ofs += nw;
} }
......
...@@ -177,7 +177,7 @@ public: ...@@ -177,7 +177,7 @@ public:
: _boxWidth(0), _boxHeight(0) : _boxWidth(0), _boxHeight(0)
{ {
setParamsFrom(params); setParamsFrom(params);
_minSize = getParameter<unsigned>(params, "min_size"); _minSize = getParameter<float>(params, "min_size");
CV_Assert(_minSize > 0); CV_Assert(_minSize > 0);
_flip = getParameter<bool>(params, "flip"); _flip = getParameter<bool>(params, "flip");
......
...@@ -282,6 +282,7 @@ TEST(Layer_Test_Eltwise, Accuracy) ...@@ -282,6 +282,7 @@ TEST(Layer_Test_Eltwise, Accuracy)
TEST(Layer_Test_PReLU, Accuracy) TEST(Layer_Test_PReLU, Accuracy)
{ {
testLayerUsingCaffeModels("layer_prelu", DNN_TARGET_CPU, true); testLayerUsingCaffeModels("layer_prelu", DNN_TARGET_CPU, true);
testLayerUsingCaffeModels("layer_prelu_fc", DNN_TARGET_CPU, true, false);
} }
//template<typename XMat> //template<typename XMat>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment