Unpickling torch tensor from Database

I have used pickle to store my tensors in a database. I am trying to get them out and un-serialize them using pickle again.


Where val represents the pytorch tensor in serialized string form. I get this error:
TypeError: a bytes-like object is required, not 'str'
Are any of you storing your tensors in a database? How do you do this?

You could try to decode the string first via:

unpickled = pickle.loads(codecs.decode(pickled, "base64"))

using the right encoding.