Repository: opencv
Issue: Prelu from Tensorflow.keras (assert m.total() == outCn)
Labels: category: dnn

I built latest opencv c++ from source on windows_x64, (this include [PR #16983](https://github.com/opencv/opencv/commit/5da4bb7e8874b9082e7e9b03ce0649f96a860f76))
I am aware that opencv recently added the support of PRelu from tensorflow. and that is why I built from source.

I am trying a very simple model (that is written in python using tensorflow 1.15):

```
import tensorflow as tf
from tensorflow import keras

def build_model(net_input_dim=112):
    inputs = keras.layers.Input((net_input_dim, net_input_dim, 3), name="input")
    x = keras.layers.Conv2D(filters=1, kernel_size=3, strides=1, name="conv2d")(inputs)
    x = keras.layers.PReLU(name="prelu")(x)
    return keras.models.Model(inputs, x, name='small_net')
```

I freezed this model. 
[opencv_issue.zip](https://github.com/opencv/opencv/files/4608688/opencv_issue.zip)

to call this freezed model from c++:
```
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>

void main() {
int network_input_size = 112;
cv::dnn::Net net = cv::dnn::readNetFromTensorflow("model.pb");
cv::Mat input_image = cv::imread("any_colored_image.jpg", 1);
cv::Mat inputBlob = cv::dnn::blobFromImage(input_image, 1.0 / 255.0, cv::Size(network_input_size, network_input_size));
net.setInput(inputBlob);
cv::Mat out;
net.forward(out);
}
```

when **net.forward** is run. I am getting the following error:
(m.isContinuous() && m.type() == CV_32F && (int)m.total() == outCn) in cv::dnn::ConvolutionLayerImpl::forward, file "opencv-master\modules\dnn\src\layers\convolution_layer.cpp, line 1425

the failure is in the following line:
CV_Assert(m.isContinuous() && m.type() == CV_32F && (int)m.total() == outCn);
m.total() is the width x height = 1 x 12100, while outCn is 1 and that's why it's failing.

I already checked similar issue ([13384](https://github.com/opencv/opencv/issues/13384))

##### System information (version)
- OpenCV > 4.3 (master) - built from source
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2017
- Python 3.7
- tensorflow 1.15

to Freeze the model:
```
from tensorflow.keras import backend as K

def freeze_session(session, keep_var_names=None, output_names=None, clear_devices=True):
    graph = session.graph
    with graph.as_default():
        freeze_var_names = list(set(v.op.name for v in tf.global_variables()).difference(keep_var_names or []))
        output_names = output_names or []
        output_names += [v.op.name for v in tf.global_variables()]
        input_graph_def = graph.as_graph_def()
        if clear_devices:
            for node in input_graph_def.node:
                node.device = ""
        frozen_graph = tf.graph_util.convert_variables_to_constants(
            session, input_graph_def, output_names, freeze_var_names)
        return frozen_graph

model = build_model()

frozen_graph = freeze_session(K.get_session(),
                              output_names=[out.op.name for out in model.outputs])

tf.compat.v1.train.write_graph(frozen_graph, "D:/", "model.pb", as_text=False)
```