For the following code:
document_vectors = dict()
for label in d2v_model.docvecs.doctags:
vector = [ v for v in d2v_model.docvecs[label]]
document_vectors[label] = list(vector)
document_vectors_file ="../results/amazon_hierarchical_document_vectors.json"
with open(document_vectors_file, "w") as outfile:
print "Writing document vectors .."
json.dumps(document_vectors, outfile)
I am getting:
TypeError: 0.031942371 is not JSON serializable
Debugging it shows me that I'm indeed having here a dict()
of list()
(I also tried to use just a simple array) but it's not working. Why?