model_dict = torch.load(save_path)
                fp = open('model_parameter.bin', 'wb')
                weight_count = 0
                num=1
                for k, v in model_dict.items():
                    print(k,num)
                    num=num+1
                    if 'num_batches_tracked' in k:
                        continue
                    v = v.cpu().numpy().flatten()
                    for d in v:
                        fp.write(d)
                        weight_count+=1
                print('model_weight has Convert Completely!',weight_count)

 

相关文章:

  • 2021-11-09
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2022-01-28
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
相关资源
相似解决方案