python的其他知识
1.帮助
dir()和help()
import torch
dir(torch.cuda) #查看torch.cuda下有那些东西
help(torch.cuda.is_available) # 查看torch.cuda.is_available的使用
2.__call__()
__call__()的功能类似于在类中重载 () 运算符,使得类实例对象可以像调用普通函数那样,以“对象名()”的形式使用。
参考:链接
3.items()
Python 字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。