Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
206b546e
Commit
206b546e
authored
Jun 15, 2019
by
gal0is
Committed by
VonChenPlus
Jul 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tensroflow support maxpoolgrad
parent
69560588
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
max_unpooling_layer.cpp
modules/dnn/src/layers/max_unpooling_layer.cpp
+9
-3
tf_importer.cpp
modules/dnn/src/tensorflow/tf_importer.cpp
+18
-0
test_tf_importer.cpp
modules/dnn/test/test_tf_importer.cpp
+7
-0
No files found.
modules/dnn/src/layers/max_unpooling_layer.cpp
View file @
206b546e
...
@@ -43,12 +43,18 @@ public:
...
@@ -43,12 +43,18 @@ public:
std
::
vector
<
MatShape
>
&
outputs
,
std
::
vector
<
MatShape
>
&
outputs
,
std
::
vector
<
MatShape
>
&
internals
)
const
CV_OVERRIDE
std
::
vector
<
MatShape
>
&
internals
)
const
CV_OVERRIDE
{
{
CV_Assert
(
inputs
.
size
()
==
2
);
CV_Assert
(
inputs
.
size
()
==
2
||
inputs
.
size
()
==
3
);
CV_Assert
(
total
(
inputs
[
0
])
==
total
(
inputs
[
1
]));
CV_Assert
(
total
(
inputs
[
0
])
==
total
(
inputs
[
1
]));
MatShape
outShape
=
inputs
[
0
];
MatShape
outShape
;
if
(
inputs
.
size
()
==
2
)
{
outShape
=
inputs
[
0
];
outShape
[
2
]
=
(
outShape
[
2
]
-
1
)
*
poolStride
.
height
+
poolKernel
.
height
-
2
*
poolPad
.
height
;
outShape
[
2
]
=
(
outShape
[
2
]
-
1
)
*
poolStride
.
height
+
poolKernel
.
height
-
2
*
poolPad
.
height
;
outShape
[
3
]
=
(
outShape
[
3
]
-
1
)
*
poolStride
.
width
+
poolKernel
.
width
-
2
*
poolPad
.
width
;
outShape
[
3
]
=
(
outShape
[
3
]
-
1
)
*
poolStride
.
width
+
poolKernel
.
width
-
2
*
poolPad
.
width
;
}
else
outShape
=
inputs
[
2
];
outputs
.
clear
();
outputs
.
clear
();
outputs
.
push_back
(
outShape
);
outputs
.
push_back
(
outShape
);
...
@@ -71,7 +77,7 @@ public:
...
@@ -71,7 +77,7 @@ public:
inputs_arr
.
getMatVector
(
inputs
);
inputs_arr
.
getMatVector
(
inputs
);
outputs_arr
.
getMatVector
(
outputs
);
outputs_arr
.
getMatVector
(
outputs
);
CV_Assert
(
inputs
.
size
()
==
2
);
CV_Assert
(
inputs
.
size
()
==
2
||
inputs
.
size
()
==
3
);
Mat
&
input
=
inputs
[
0
];
Mat
&
input
=
inputs
[
0
];
Mat
&
indices
=
inputs
[
1
];
Mat
&
indices
=
inputs
[
1
];
...
...
modules/dnn/src/tensorflow/tf_importer.cpp
View file @
206b546e
...
@@ -1370,6 +1370,24 @@ void TFImporter::populateNet(Net dstNet)
...
@@ -1370,6 +1370,24 @@ void TFImporter::populateNet(Net dstNet)
connectToAllBlobs
(
layer_id
,
dstNet
,
parsePin
(
layer
.
input
(
0
)),
id
,
layer
.
input_size
());
connectToAllBlobs
(
layer_id
,
dstNet
,
parsePin
(
layer
.
input
(
0
)),
id
,
layer
.
input_size
());
}
}
else
if
(
type
==
"MaxPoolGrad"
)
{
CV_Assert
(
layer
.
input_size
()
==
3
);
layerParams
.
set
(
"pool_k_h"
,
0
);
layerParams
.
set
(
"pool_k_w"
,
0
);
layerParams
.
set
(
"pool_stride_h"
,
0
);
layerParams
.
set
(
"pool_stride_w"
,
0
);
layerParams
.
set
(
"pool_pad_h"
,
0
);
layerParams
.
set
(
"pool_pad_w"
,
0
);
int
id
=
dstNet
.
addLayer
(
name
,
"MaxUnpool"
,
layerParams
);
layer_id
[
name
]
=
id
;
connect
(
layer_id
,
dstNet
,
parsePin
(
layer
.
input
(
2
)),
id
,
0
);
connect
(
layer_id
,
dstNet
,
parsePin
(
layer
.
input
(
1
)
+
":1"
),
id
,
1
);
connect
(
layer_id
,
dstNet
,
parsePin
(
layer
.
input
(
0
)),
id
,
2
);
}
else
if
(
type
==
"Placeholder"
)
else
if
(
type
==
"Placeholder"
)
{
{
if
(
!
hasLayerAttr
(
layer
,
"dtype"
)
||
if
(
!
hasLayerAttr
(
layer
,
"dtype"
)
||
...
...
modules/dnn/test/test_tf_importer.cpp
View file @
206b546e
...
@@ -218,6 +218,13 @@ TEST_P(Test_TensorFlow_layers, pooling)
...
@@ -218,6 +218,13 @@ TEST_P(Test_TensorFlow_layers, pooling)
runTensorFlowNet
(
"reduce_mean"
);
// an average pooling over all spatial dimensions.
runTensorFlowNet
(
"reduce_mean"
);
// an average pooling over all spatial dimensions.
}
}
TEST_P
(
Test_TensorFlow_layers
,
max_pool_grad
)
{
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE
);
runTensorFlowNet
(
"max_pool_grad"
);
}
// TODO: fix tests and replace to pooling
// TODO: fix tests and replace to pooling
TEST_P
(
Test_TensorFlow_layers
,
ave_pool_same
)
TEST_P
(
Test_TensorFlow_layers
,
ave_pool_same
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment