0%

修改配置

1
2
3
4
[
{ "keys": ["super+shift+u"], "command": "split_selection_into_lines" },

]

1
2
3
import torch
# after import torch, add this
torch.backends.cudnn.benchmark=True

保存模型

1
2
3
4
5
6
torch.save(the_model.state_dict(), PATH)
the_model = TheModelClass(*args, **kwargs)
the_model.load_state_dict(torch.load(PATH))

torch.save(the_model, PATH)
the_model = torch.load(PATH)

Variable to tensor

1
2
3
4
# for gpu
t.data.cpu().numpy()
# for cpu
t.data.numpy()

类型转换

1
2
a = a.type('torch.DoubleTensor') # for converting to double tensor (cpu)
a.double()

pytorch版本

1
2
import torch
print(torch.__version__)

1
2
3
4
5
6
7
8
>>>"{} {}".format("hello", "world")    # 不设置指定位置,按默认顺序
'hello world'

>>> "{0} {1}".format("hello", "world") # 设置指定位置
'hello world'

>>> "{1} {0} {1}".format("hello", "world") # 设置指定位置
'world hello world'

无法同步服务器代码, 下载安装最新版pycharm

  1. 只能通过 包名.模块名来import具体函数
  2. from .bbb import a当你导入一个包的时候,实际上是导入了这个包的init.py的文件,所以,如果你在init里面写入了其他的import功能,就等于是在初始化的时候帮忙导入了其他东西

https://blog.csdn.net/GeekLeee/article/details/52505233

1
2
3
self.opt = self.parser.parse_args("-demo "
"./images/h36m_1214.png -loadModel "
"./models/hgreg-3d.pth".split())

1
2
3
import sys

print(sys.executable)

1
2
pip install IPython==5.0 --user
pip install jupyter --user