Issue saving training data
Over-TheRainbow opened this issue · comments
I put some circuits and compiled circuits I previously made into the package folders and tried to generate training data and save, like in the readme in the home page:
res = predictor.generate_trainingdata_from_qasm_files()
ml.helper.save_training_data(res)
I got this error:
Traceback (most recent call last):
File "....../mqt_compile_for_training.py", line 13, in <module>
ml.helper.save_training_data(res)
File "....../mqt/predictor/ml/helper.py", line 203, in save_training_data
data = np.asarray(training_data)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (560, 2) + inhomogeneous part.
Printing a line of training_data
gives data in this form:
[0, 0, 0, 66, 0, 0, 0, 0, 169, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 10, 0.05303030303030303, 0.13636363636363635, 0.28085106382978725, 0.703125, 0.9121212121212121], 4)
Printing 560 lines of this, the dimensions do not seem to change. I'm not exactly sure what was causing this error, especially since loading and re-saving the provided training_data.npy
seems to work okay.
Hi @Over-TheRainbow, thanks again for this issue and also all your other contributions to MQT Predictor. I helps us a lot to improve the software and is highly appreciated. I will have a look into it and come back to you afterwards.
Which version of mqt.predictor
are you using?
I was able to reproduce you error on the main
branch and added a quickfix on the fix_saving_bug
branch you can find here.
Could you verify whether this solves your issue?
Yup! It seems to save now, thank you!