
python
Oshrin
「努力すればするほど幸運がある」をずっと信じている!
The only real way to learn is through practice and actual coding.
展开
-
PyTorch中的BatchNorm2d层
先来看看pytorch中对于类的定义:CLASS torch.nn.BatchNorm2d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)解析一下每个参数的作用:num_features:BatchNorm是针对每一个通道做的,所以这里应该填写(N, C, H, W)中的C...原创 2019-11-12 11:23:01 · 1172 阅读 · 0 评论 -
Module.named_parameters()、Module.named_children()与Module.named_modules()的区别
在代码里面输出一下子:import torchimport torch.nn as nnclass Net(nn.Module): def __init__(self): super().__init__() self.fc1 = nn.Linear(3, 4) self.relu1 = nn.ReLU() se...原创 2019-11-06 21:02:32 · 2534 阅读 · 0 评论 -
Error(s) in loading state_dict for DataParallel
关于PyTorch模型保存与导入的一些注意点:1.没有使用并行计算:import torch.nn as nnclass Net(nn.Module): def __init__(self): super().__init__() self.conv1 = nn.Conv2d(2, 2, 1) self.linear = nn...原创 2019-11-05 13:54:17 · 5368 阅读 · 1 评论 -
Python的局部变量和全局变量
num = 10def func(): x = num + 10 print(x)def func2(): # 报错,因为num作为左值被认为是局部变量了,不能在赋值之前使用 # num = num + 10 print(num)func()func2()# 报错,不存在x# print(x)print(num)# 以下是输出...原创 2019-11-04 15:59:24 · 266 阅读 · 0 评论