打印pytorch每層參數。
采用的是直接在層中加入txt的寫入。需要修改的文件位置:./site-packages/torch/nn/modules/
Conv2D
v = F.conv2d(input, self.weight, self.bias, self.stride,self.padding, self.dilation, self.groups) v = v.detach() v = v.cpu().numpy().flatten() fp = open('conv2d.txt', 'w') for d in v: fp.write(str(d)+'\n') print('conv2d has Convert Completely!') fp.close() |
輸入數據input
v = label.detach() v = v.cpu().numpy().flatten() fp = open('input.txt', 'w') for d in v: fp.write(str(d)+'\n') print('input has Convert Completely!') fp.close() |
其它層仿照上面的就可以了。