adj_mx = tf.SparseTensor(indices=indices, values=values, dense_shape=dense_shape)
adj_mx_serialized = tf.io.serialize_sparse(adj_mx).numpy().tobytes()
I did this and saved as blob to sql.
I know what I did is probably a mistake, but I didn’t notice it at the time. And I really would love to be able to de-serialize it without needing to serialize it again, correctly this time. I have done this for half a million matrices, so I want to know if it is remotely possible to reverse this serialization.
According to TensorFlow, the serialize_sparse function returns:
“A 3-vector (1-D Tensor), with each column representing the serialized SparseTensor’s indices, values, and shape (respectively).”
#...
sparse_adj = nx.adjacency_matrix(G, weight='weight')
coo = sparse_adj.tocoo()
indices = np.mat([coo.row, coo.col]).transpose()
values = coo.data
dense_shape = (aa_limit, aa_limit)
adj_mx = tf.SparseTensor(indices=indices, values=values, dense_shape=dense_shape)
This was the construction.
I know how many indices we have (i mean i know len(coo.row)
which is equal to len(coo.col)
). The values are floats.
Do I have any chance?