CEA-LIST / N2D2

N2D2 is an open source CAD framework for Deep Neural Network simulation and full DNN-based applications building.
Other
146 stars 36 forks source link

ONNX model and Database Label map #77

Closed andreistoian closed 3 years ago

andreistoian commented 3 years ago

Hi,

I am calibrating an ONNX model exported from pytorch. The calibration works but I want to check accuracy. However, from my understandingm the DIR_Database generates labels and label ids from the directory structure (are labels sorted alphabetically to generate ids?).

I would like to specify a label map so the outputs of the ONNX model correspond to the right labels that are read from the directory structure. Is this possible ?

olivierbichler-cea commented 3 years ago

Hi, Yes indeed the default order for the labels in this case is the alphabetical order of the directories. You can specify a custom label mapping in the Target:

[softmax]
...

[softmax.Target]
LabelsMapping=labels_mapping.dat

With labels_mapping.dat containing the mapping (labels name start with "/" when generated from a directory structure):

# label_name output_neuron
/folder1 0
/folder2 2
/folder3 1
andreistoian commented 3 years ago

Thanks, but I'm not yet able to test it out.

I want to test on WAV files which are supported in N2D2 in PCM format (fmt=1). However, the network is trained on normalized wave files (with float values between -1 and 1, I'm guessing by dividing the 16bit PCM values by 32767). LibRosa saves WAV files in fmt=3 WAVE_FORMAT_IEEE_FLOAT which is not supported by N2D2. I will thus use PCM format WAV.

How can I rescale the the PCM values read by the N2D2 WAV reader? I could not find a tutorial for the AffineTransformation, is this the way to do it?

UPDATE: I added FLOAT32 format to the Wav Reader: add_wav_float32.txt

I'll open another issue with further problems.

olivierbichler-cea commented 3 years ago

Would you mind to open a pull request for your float32 format integration? Thanks

andreistoian commented 3 years ago

Ok, done!