urinieto / msaf

Music Structure Analysis Framework
MIT License
490 stars 78 forks source link

Question - Labelling algorithm outputting different results on same file #95

Closed chriswang030 closed 5 years ago

chriswang030 commented 5 years ago

When doing the following on the same audio file, I get different outputs for labels. boundaries, labels = msaf.process(audio_file, boundaries_id='olda', labels_id='cnmf')

I know the numerical values change sometimes, but the outputs I'm getting are [5.0, 1.0, 4.0, 2.0, 1.0, 2.0, 1.0, 3.0, 3.0, 4.0, 1.0, 1.0, 4.0] and [5.0, 1.0, 1.0, 3.0, 2.0, 1.0, 2.0, 3.0, 3.0, 4.0, 2.0, 1.0, 1.0], which do not have the same structure.

Is there a reason for this?

Thanks

urinieto commented 5 years ago

CNMF is a stochastic algorithm, so the same result is not guaranteed for different runs. You may overcome this buy initializing the random process with the same seed.

chriswang030 commented 5 years ago

Ah, that's what I figured, but I couldn't find the place where the seed is generated. Could you point that out to me?

Thanks a lot for your time.

urinieto commented 5 years ago

The stochastic process originates in the pymf module, which gets called from here: https://github.com/urinieto/msaf/blob/master/msaf/algorithms/cnmf/segmenter.py#L40

More specifically, pymf uses a random process when initializing the factorized matrices: https://github.com/urinieto/msaf/blob/master/msaf/pymf/nmf.py#L116-L120

chriswang030 commented 5 years ago

Okay, thanks a lot!