python numpy读取二进制数据

import numpy as np

q_f = open('weight','rb')
weight = np.fromfile(q_f, dtype=np.int16)
weight = np.reshape(weight,(512,512)).T
weight = weight.flatten()
q_f.close()

fo = open("weight2", "wb")
fo.write(weight)
fo.close()

  

posted @ 2021-07-05 15:18  cydcyd  阅读(681)  评论(0编辑  收藏  举报