revert to using fixed RNG in EM, otherwise the algorithm becomes non-deterministic and the test fails sometimes. in the meantime, EM needs to switch to more robust cv::kmeans instead of CvEM::kmeans.
This commit is contained in:
parent
e6aba3e51c
commit
bc21cc6fe9
@ -581,7 +581,7 @@ void CvEM::kmeans( const CvVectors& train_data, int nclusters, CvMat* labels,
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
cv::RNG* rng = &cv::theRNG();
|
||||
cv::RNG rng(0xFFFFFFFF);
|
||||
int i, j, k, nsamples, dims;
|
||||
int iter = 0;
|
||||
double max_dist = DBL_MAX;
|
||||
@ -605,7 +605,7 @@ void CvEM::kmeans( const CvVectors& train_data, int nclusters, CvMat* labels,
|
||||
{
|
||||
for( i = 0; i < nsamples; i++ )
|
||||
labels->data.i[i] = i*nclusters/nsamples;
|
||||
cvRandShuffle( labels, &rng->state );
|
||||
cvRandShuffle( labels, &rng.state );
|
||||
}
|
||||
|
||||
for( ;; )
|
||||
@ -702,7 +702,7 @@ void CvEM::kmeans( const CvVectors& train_data, int nclusters, CvMat* labels,
|
||||
const float* s;
|
||||
for( j = 0; j < 10; j++ )
|
||||
{
|
||||
i = (*rng)(nsamples);
|
||||
i = rng(nsamples);
|
||||
if( counters->data.i[labels->data.i[i]] > 1 )
|
||||
break;
|
||||
}
|
||||
@ -738,7 +738,7 @@ void CvEM::kmeans( const CvVectors& train_data, int nclusters, CvMat* labels,
|
||||
if( counters->data.i[k] == 0 )
|
||||
for(;;)
|
||||
{
|
||||
i = (*rng)(nsamples);
|
||||
i = rng(nsamples);
|
||||
j = labels->data.i[i];
|
||||
if( counters->data.i[j] > 1 )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user