Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Iterate over multiple vectors of uneven Mat

Hi,

I have two vectors with uneven Mat

vector<Mat> delta_nabla_w = GetWeightsMatDelta();  // [Mat(10, 20), Mat(20, 40), Mat(40, 10)]
vector<Mat> nabla_w = GetWeightsMatZeros(); // [Mat(10, 20), Mat(20, 40), Mat(40, 10)]

I need to iterate over both of them at the same time and sum them up. I've tried this:

for(int j = 0; j < nabla_w.size(); j++) {
     nabla_w.at<Mat>(j) += delta_nabla_w.at<Mat>(j);
}

But it gives me an error Mat does not refer to a value, which kind of make sense. Could you please help me on this one?