pyAudioClassification
pyAudioClassification copied to clipboard
model.predict dropping 1 label
I'm training a model using the freesound data from Kaggle: https://www.kaggle.com/c/freesound-audio-tagging/data
I'm training with 41 classes, but am only getting 40 results. I'm following the basic code from Readme.
Note: I'm now passing in 41 classes and am getting 41 results.
model = train(features, labels, num_classes = len(np.unique(labels)), epochs = 500)
Ah, I think it's here.
https://github.com/98mprice/pyAudioClassification/blob/master/pyaudioclassification/init.py#L30
Doing np.max takes ignores zero and gives you off by one errors.
This would fix it len(np.unique(labels). I can submit a PR if you agree? @98mprice
Also,
Why are you subtracting by 1 here? https://github.com/98mprice/pyAudioClassification/blob/master/pyaudioclassification/init.py#L42
Hi @ryanbales
Good find! I think you're probably right about this being the cause of the off-by-one error.
To be honest, I can't remember exactly why I subtracted 1 there but it may have been because I copied the code from some of my other projects and didn't pay attention when I did so. Unfortunately I'm currently unable to test whether removing that -1 will fix the issue, but please feel free to submit a PR regardless and I'll marge it and deploy the new release to PyPi when I get home.
Thanks!
@ryanbales Did the fix work? I have been trying to make it work using your suggestion, but I am getting this error:
ValueError: Error when checking target: expected activation_5 to have shape (2,) but got array with shape (1,)
The error is raised here:
File "test.py", line 36, in
Please let me know if I am doing something wrong over here.
@raifofcl Did you find any solution for your error ? I got exactly the same.
@lpnaunau I cant say it to be a solution, but I found a workaround. I put an empty folder in the data folder. The condition for this to work is the empty folder must be at the first index after the sort. In order to achieve this, I put the folders in this format:
- 100 - Nothing
- 101 - Dog
- 102 - Cat
@raifofcl Thanks !
I am also getting same errors. Please guide me , how did you solve this .
model = train(features, labels, epochs=100, print_summary=True) File "........\pyaudioclassification_init_.py", line 49, in train model.fit(x, y, batch_size=64, epochs=epochs, verbose=verbose)
Even though i changed in format of 100-nothing 101-cat 102-dog
still i am getting errors.
@raifofcl I tried your solution but still getting the same issue. Thanks anyway for your help !
@ignvinay Is all that folder contains .ogg or .wav files. It supports for those file formats only.
@ryanbales I am doing like what you suggested and got the error as
File "test.py", line 25, in