Skip to content

Instantly share code, notes, and snippets.

@nlpjoe
Last active September 17, 2020 09:12
Show Gist options
  • Save nlpjoe/4f8961b5ea64685c9ff5f9c0ff3d74dc to your computer and use it in GitHub Desktop.
Save nlpjoe/4f8961b5ea64685c9ff5f9c0ff3d74dc to your computer and use it in GitHub Desktop.
[utils] #ml #pytorch
oss连接工具 IO
odps读table
pytorch训练/测试 读odps表 dataset
# Print model's state_dict
print("Model's state_dict:")
for param_tensor in model.state_dict():
    print(param_tensor, "\t", model.state_dict()[param_tensor].size())

# Print optimizer's state_dict
print("Optimizer's state_dict:")
for var_name in optimizer.state_dict():
    print(var_name, "\t", optimizer.state_dict()[var_name])

压缩包

import tarfile
tar = tarfile.open("sample.tar", "w")
for name in ["foo", "bar", "quux"]:
    tar.add(name)
tar.close()

解压包

import tarfile
tar = tarfile.open("sample.tar.gz")
tar.extractall()
tar.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment