Mat::reshape is called incorrectly in EM::setTrainData (Bug #3674)


Added by S Yoon almost 11 years ago. Updated over 9 years ago.


Status:Open Start date:2014-05-04
Priority:Normal Due date:
Assignee:S Yoon % Done:

0%

Category:ml
Target version:-
Affected version:branch '2.4' (2.4-dev) Operating System:Windows
Difficulty:Easy HW Platform:x64
Pull request:

Description

I am using openCV 2.4.9, compiled on a Win 7 64-bit box.

When using EM (em.cpp) with the option of starting with the E-step, one provides the initial means, covariance matrices, and weights. The variable weights is a number of clusters by 1 matrix/vector. In em.cpp, in the function EM::setTrainData, the variable weights is "reshaped" to a 1 x number of clusters vector using the function call

weights.reshape(1, 1)

Unfortunately, when the input is a number of clusters X 1 vector, this reshape does nothing, resulting in a bad initial weight vector (because subsequently the initial weights are computed based on the number of columns).

I also tested the Mat::reshape function independently, and I confirmed that the function call does nothing for a N X 1 vector/matrix.


Associated revisions

Revision 2bacd8b7
Added by be rak almost 11 years ago

2 fixed unassigned reshapes in em (#3674)

Revision 98f9a013
Added by Vadim Pisarevsky about 10 years ago

Merge pull request #3674 from jet47:colorize-run-test-script-2.4

History

Updated by be rak almost 11 years ago

since reshape() returns a new Mat header (it does not work inplace), it seems, that there's an assignment missing:

weights = weights.reshape(1,1);

(without it, the reshape operation just gets ignored)

Updated by Andrew Senin almost 11 years ago

be rak, thanks for nice catch!

Could you or S Yoon create a fixing pull request on this (http://code.opencv.org/projects/opencv/wiki/How_to_contribute)? Your contribution is really appreciated!

  • Status changed from New to Open
  • Difficulty set to Easy
  • Assignee set to S Yoon
  • Subject changed from Mat::reshape to Mat::reshape is called incorrectly in EM::setTrainData

Updated by be rak almost 11 years ago

@S Yoon , do you have some test code for the EM ?

i'm having a bit of trouble reproducing it.

seems, if i want to test the EM::START_E_STEP flag, i need to supply valid weights,means and covs, what did you use there ?

Updated by Alexander Shishkov almost 11 years ago

  • Category set to ml

Updated by Maksim Shabunin over 9 years ago

Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4740

Also available in: Atom PDF