在程序中输出临时文件大小
1
2
3
4
5
6
def print_size_of_model(model):
torch.save(model.state_dict(), "temp.p")
print('Size (MB):', os.path.getsize("temp.p")/2**20)
os.remove('temp.p')
print_size_of_model(model)
1
2
3
4
5
6
def print_size_of_model(model):
torch.save(model.state_dict(), "temp.p")
print('Size (MB):', os.path.getsize("temp.p")/2**20)
os.remove('temp.p')
print_size_of_model(model)