Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when training model - Division by zero when all values in an array are 0 #47

Open
alastair opened this issue Jul 20, 2016 · 11 comments
Labels

Comments

@alastair
Copy link
Member

https://acousticbrainz.org/datasets/7a052ef4-cad2-4362-a075-5933b20609f0

Traceback (most recent call last):
  File "/home/acousticbrainz/ve/local/lib/python2.7/site-packages/gaia2/classification/classificationtask.py", line 195, in <module>
    task.run(className, outfilename, param, dsname, gtname, evalconfig)
  File "/home/acousticbrainz/ve/local/lib/python2.7/site-packages/gaia2/classification/classificationtask.py", line 177, in run
    confusion = evaluateNfold(evalparam['nfold'], ds, gt, trainerFun, **trainingparam)
  File "/home/acousticbrainz/ve/local/lib/python2.7/site-packages/gaia2/classification/evaluation.py", line 116, in evaluateNfold
    classifier = trainingFunc(trainds, traingt, *args, **kwargs)
  File "/home/acousticbrainz/ve/local/lib/python2.7/site-packages/gaia2/classification/classifier_SVM.py", line 35, in train_SVM
    ds = transform(ds, 'normalize', { 'independent': True })
  File "/home/acousticbrainz/ve/local/lib/python2.7/site-packages/gaia2/__init__.py", line 4601, in transform
    return analyzer.analyze(dataset).applyToDataSet(dataset)
  File "/home/acousticbrainz/ve/local/lib/python2.7/site-packages/gaia2/__init__.py", line 1997, in analyze
    return _gaia2.Analyzer_analyze(self, *args)
Exception: Normalize: Division by zero in .tonal.chords_histogram
@alastair
Copy link
Member Author

Only seems to happen with some parameter combinations

@ybayle
Copy link

ybayle commented Sep 28, 2016

@alastair :
Which parameter combinations? I reproduce this issue everytime on Mac and Debian with the latest version just by launching train_model_from_sigs.py without any param excepting the name of the folder containing the .sig.

@dbogdanov
Copy link
Member

This happens we you a trying to normalize a descriptors which value is always constant across dataset. I've improved the error message in the last commit. Make sure the "cleaner" transformation is applied before doing "normalize". If it is applied still there is error, we'll need to dig into this problem further.

@dbogdanov
Copy link
Member

Cleaner IS applied before "normalize" in train_SVM.py

@ybayle
Copy link

ybayle commented Sep 28, 2016

Indeed, "cleaner" is applied before "normalize" in "classifier_SVM.py".
I just launched:

  1. streaming_music_extractor (on my songs)
  2. json_to_sig.py (on essentia extracted features)
  3. train_model_from_sigs.py

And I did not configure anything and I see the "division by zero" error.

@ybayle
Copy link

ybayle commented Sep 28, 2016

The programm displays the error message for
"Exception: Normalize: Division by zero in .tonal.chords_histogram"
but also for .barkbands.mean if this info can help?
If you can't reproduce the bug I can send you example files that reproduce this error. (2 classes and 2 files per class)

@dbogdanov
Copy link
Member

Yes, please send me your example and I will run it.

@ybayle
Copy link

ybayle commented Sep 29, 2016

You can find the example here :
https://github.com/ybayle/gaiaWrapper
You can launch it with :
python gaiaWrapper.py data

@dbogdanov
Copy link
Member

Testing this example now. Btw, no need to use export PYTHONPATH inside your script. You can simply do from gaia2.scripts.classification import json_to_sig, train_model_from_sigs ;)

@ybayle
Copy link

ybayle commented Sep 29, 2016

Thanks.
As concerns the "export PYTHONPATH", I was doing it because gaia2 wasn't found at all after its installation. I should have been adding it permanently to my .bash_rc instead of calling it in my python file.

@ybayle
Copy link

ybayle commented Oct 13, 2016

@dbogdanov Did you have problems while testing?

@dbogdanov dbogdanov added the bug label Apr 19, 2018
@alastair alastair changed the title Error when training model Error when training model - Division by zero when all values in an array are 0 Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants