I have a simple thing to do, read some vectors and write them in a file.
The vectors are 1024 dimensional.
for emb in src:
print(len(emb[0].detach().cpu().numpy())) #--> prints 1024!
f.write(np.array2string(emb[0].detach().cpu().numpy(), separator=', ') + " \n")
My file looks like this:
[-0.18077464, -0.02889516, 0.33970496, ..., -0.28685367, 0.00343359,
-0.00380083]
[-0.04554039, 0.0891239 , 0.0457519 , ..., -0.02622034, 0.04410202,
-0.03626832]
[ 0.2415923 , 0.36748591, -0.10974079, ..., 0.06169772, 0.0134424 ,
0.01647076]
[ 0.019123 , 0.00409475, 0.03623311, ..., -0.13063622, 0.02434589,
0.00400023]
[ 0.01281842, 0.00028924, 0.03185712, ..., -0.062907 , 0.02143336,
-0.00206215]
[ 0.01748654, 0.00136842, -0.01337154, ..., -0.04148545, 0.00875527,
-0.03006736]
So, I just can't access my vectors, 1024 dimension is transformed to whatever 6 or 7 dimensional vector + .... :(
How can I write vectors to my file correctly?
Cheers :)
machine-learning- kindly do not spam the tag (removed).array2stringis doing the same thing asstr(x)orprint(x). It's the summarized output intended primarily for quick interactive views. It's not intended saving and reloading.csvformat,np.savetxtis good basic choice for writing a 2d array. The result should be readable withnp.genfromtxt.