diff --git a/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp b/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp index 96bcdbd308..0f9670e8a4 100644 --- a/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp +++ b/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp @@ -787,7 +787,7 @@ void RemoveIdentityOps(tensorflow::GraphDef& net) const tensorflow::NodeDef &layer = net.node(li); String type = layer.op(); - if (type == "Identity" || type == "Dropout") { + if (type == "Identity" || type == "Dropout" || type == "PlaceholderWithDefault") { identity_ops_idx.push_back(li); identity_ops[layer.name()] = layer.input(0); } @@ -1031,7 +1031,7 @@ void removePhaseSwitches(tensorflow::GraphDef& net) } } nodesToRemove.push_back(i); - if (node.op() == "Merge") + if (node.op() == "Merge" || node.op() == "Switch") mergeOpSubgraphNodes.push(i); } } diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp index dac55d60b0..dd10a4d68b 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -729,6 +729,7 @@ TEST_P(Test_TensorFlow_layers, subpixel) TEST_P(Test_TensorFlow_layers, keras_mobilenet_head) { runTensorFlowNet("keras_mobilenet_head"); + runTensorFlowNet("keras_learning_phase"); } TEST_P(Test_TensorFlow_layers, resize_bilinear)