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

ValueError: operands could not be broadcast together with shapes (5,5) (4,4) #368

Closed
MiPlayer123 opened this issue Feb 4, 2022 · 5 comments

Comments

@MiPlayer123
Copy link

MiPlayer123 commented Feb 4, 2022

I am geting the following error when running aT.extract_features_and_train(["<path>\Audio Classification\BabyCry","<path>\Audio Classification\GlassBreaking", "<path>\Audio Classification\Gunshot", "<path>\Audio Classification\Falling", "<path>\Audio Classification\Background"], 1.0, 1.0, aT.shortTermWindow, aT.shortTermStep, "randomforest", "randomForest2", False). All the data in the folders are .wav files

<more outputs>
Feature extraction complexity ratio: 26.6 x realtime
Analyzing file 1 of 3: <path>\Audio Classification\Background\2019-05-24-12-26-34-355000__1.wav
Analyzing file 2 of 3: <path>\Audio Classification\Background\2019-05-24-12-26-34-355000__22.wav
Analyzing file 3 of 3:<path>\Audio Classification\Background\2019-05-24-12-26-34-355000__24.wav
Feature extraction complexity ratio: 25.8 x realtime
Param = 10.00000 - classifier Evaluation Experiment 1 of 26
Traceback (most recent call last):
  File "<path>\main.py", line 3, in <module>
    aT.extract_features_and_train(["<path>\Audio Classification\BabyCry","<path>\GlassBreaking", "D:\Research\Datasets\Audio Classification\Gunshot", "<path>\Audio Classification\Falling", "<path>\Audio Classification\Background"], 1.0, 1.0, aT.shortTermWindow, aT.shortTermStep, "randomforest", "randomForest2", False)
  File "<path>t\anaconda3\lib\site-packages\pyAudioAnalysis\audioTrainTest.py", line 298, in extract_features_and_train
    best_param = evaluate_classifier(features, class_names, classifier_type,
  File "<path>\anaconda3\lib\site-packages\pyAudioAnalysis\audioTrainTest.py", line 623, in evaluate_classifier
    cm = cm + cmt
ValueError: operands could not be broadcast together with shapes (5,5) (4,4) 
@tyiannak
Copy link
Owner

tyiannak commented Feb 4, 2022

You are not using the latest version of the library. That is an old bug that should be fixed by now (it randomly happened when few samples existed in any of the classes). But, in any case this is fixed in the latest version of the library, so please update your dependencies.

@MiPlayer123
Copy link
Author

I updated the library, but I am running into new errors:

Param = 10.00000 - classifier Evaluation Experiment 81 of 127
Param = 10.00000 - classifier Evaluation Experiment 82 of 127
Param = 10.00000 - classifier Evaluation Experiment 83 of 127
Param = 10.00000 - classifier Evaluation Experiment 84 of 127
Param = 10.00000 - classifier Evaluation Experiment 85 of 127
Param = 10.00000 - classifier Evaluation Experiment 86 of 127
Param = 10.00000 - classifier Evaluation Experiment 87 of 127
Param = 10.00000 - classifier Evaluation Experiment 88 of 127
Param = 10.00000 - classifier Evaluation Experiment 89 of 127
Traceback (most recent call last):
  File "D:\Research\Scripts\main.py", line 3, in <module>
    aT.extract_features_and_train(["<path>\Audio Classification\BabyCry","<path>\Audio Classification\GlassBreaking", "<path>\Audio Classification\Gunshot", "<path>\Audio Classification\Falling", "<path>\Audio Classification\Background"], 1.0, 1.0, aT.shortTermWindow, aT.shortTermStep, "randomforest", "randomForest2", False)
  File "<path>\anaconda3\lib\site-packages\pyAudioAnalysis\audioTrainTest.py", line 307, in extract_features_and_train
    best_param = evaluate_classifier(features, class_names, classifier_type,
  File <path>\anaconda3\lib\site-packages\pyAudioAnalysis\audioTrainTest.py", line 694, in evaluate_classifier
    cmt = np.insert(cmt, missing_classes, 0, axis=0)
  File "<__array_function__ internals>", line 5, in insert
  File "<path>\anaconda3\lib\site-packages\numpy\lib\function_base.py", line 4672, in insert
    old_mask[indices] = False
IndexError: index 5 is out of bounds for axis 0 with size 5

Is there a way I can resolve these issues by modifying my dataset, or is it a bug?

@tyiannak
Copy link
Owner

tyiannak commented Feb 5, 2022

Is it possible to send me the data so that I can reproduce the error?

@MiPlayer123
Copy link
Author

I figured out the issue. I only had 4 files in one of the folders while the rest had hundreds, but as soon as I added a lot more files to it worked. Let me know if you would still like the data.

@tyiannak
Copy link
Owner

tyiannak commented Feb 6, 2022

Thank for the answer @MiPlayer123 . No need to send me the data. I've added a new issue to add an error if number of samples if is not sufficient.

@tyiannak tyiannak closed this as completed Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants