# Solve the problem that python uses f.write to write the matrix into the file, the matrix data is incomplete, and there is an ellipsis in the middle

created at 11-22-2021 views: 3

## problem¶

[layer1_1[[[ 52.373936   16.00824    62.745567  ...  12.321167    2.960958
11.374744 ]
[ 16.00824    50.275608   28.002008  ...   6.575324    3.6270523
12.703771 ]
[ 62.745567   28.002008  157.73836   ...   7.091863   10.858132
27.182278 ]
...
[ 12.321167    6.575324    7.091863  ...  34.73878     3.3262274
5.7292085]
[  2.960958    3.6270523  10.858132  ...   3.3262274   7.8038836
2.569603 ]
[ 11.374744   12.703771   27.182278  ...   5.7292085   2.569603
25.078949 ]]]layer2_1[[[ 73.83229      0.7081489   17.736713   ...  19.670973     4.445404
9.527895  ]
[  0.7081489    8.336616     1.4164687  ...  13.625283     1.9007537
0.28997284]
[ 17.736713     1.4164687   43.66755    ...  17.562332     2.0960655
7.280709  ]


## solution¶

This is because print printing has limitations. You can use numpy, set the numpy print threshold to a very large value, and then change the matrix to be printed to numpy, and it will run just fine.

        np.set_printoptions(threshold=1e6)
with open(path,'a') as f:
f.write('\n')
f.write('[')
for i in range(len(target_style_representation)):
f.write(layer_name[i])
f.write('[')
f.write(str(target_style_representation[i][0].numpy()))
f.write(']')
f.write(']')


## result¶

[layer1_1[[[5.23739357e+01 1.60082397e+01 6.27455673e+01 1.05568390e+01
2.28911376e+00 4.15294123e+00 6.77726173e+00 1.70763052e+00
1.11476822e+01 9.97243583e-01 1.07449827e+01 1.95730057e+01
6.51393795e+00 7.40577650e+00 4.72515726e+00 3.39103603e+00
1.07697449e+01 5.12092590e+00 1.94210415e+01 4.23597479e+00
1.15561676e+01 7.83079863e+00 5.69148827e+00 5.83253443e-01
8.93112183e+00 2.01249814e+00 1.08564749e+01 3.50663590e+00
1.23515606e+01 8.12845898e+00 1.89898739e+01 9.90073395e+00
7.64079666e+00 2.10052338e+01 6.41636086e+00 1.76900120e+01
9.47703362e+00 1.24001722e+01 3.88660049e+00 8.29183102e+00
5.77612019e+00 6.33223915e+00 5.35460567e+00 7.50802898e+00
4.40431070e+00 2.31432462e+00 1.04304247e+01 5.26455927e+00
2.99945617e+00 2.11782598e+00 1.19995365e+01 7.72702980e+00
3.52567315e+00 3.29625206e+01 6.72306252e+00 4.78106594e+00
1.82437932e+00 2.22885246e+01 1.07932968e+01 7.53088760e+00
1.47860355e+01 1.23211670e+01 2.96095800e+00 1.13747444e+01]
[1.60082397e+01 5.02756081e+01 2.80020084e+01 3.17489090e+01
2.12840252e+01 8.52305603e+00 7.47819901e+00 1.95832658e+00
2.61529369e+01 4.34247160e+00 2.16594219e+01 5.47845764e+01
6.44918442e+00 3.19164395e+00 1.91736662e+00 5.02262878e+00
5.03537607e+00 5.34923315e+00 1.54125938e+01 7.74529314e+00

created at:11-22-2021