i am training the model on google colab…and i want to download the note2int and int2note dictionary mappings…But the contain some non ascii characters. How do I solve this proble
How to save the dictionaries
Hey @anukritigarg13
The simplest way to store a dictionary would be to use the pickle module. I’m attaching a code snippet demonstrating its use.
import pickle
a = {'hello': 'world'}
with open('filename.pickle', 'wb') as handle:
pickle.dump(a, handle)
with open('filename.pickle', 'rb') as handle:
a_loaded = pickle.load(handle)
print(a)
print(a_loaded)
Hope this helps!
I saved it using this only…but when I am saving this music21 elements…it is showung error…like it couldn’t decode char at pos this
Can you share the complete error message here? Also, ensure you are not using Python 2.x.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.