Gluon
报错:1
RuntimeError: Parameter 'stn_conv0_weight' was not initialized on context gpu(0). It was only initialized on [gpu(0)].
解决方法:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
## 提取特征层输出
### Method 1: 继承 Block, 实现 forward
... 待续
### Method 2: 使用 SymbolBlock
```python
net = gluon.model_zoo.vision.densenet(pretrained=True, ctx=ctx)
internals = net.load_params("./densenet.params", ctx=context)
out_list = [internals['densenet0_stage3_conv13_fwd_output'],
'densenet0_stage3_conv13_fwd_output']]
net = gluon.SymbolBlock(out_list, data, params=net.collect_params())
网络冻结
- 方式一: freeze 层在在 record 外面, 只 forward, 梯度不进行回传
不同层设置不同的学习率
1 | net = gluon.model_zoo.vision.densenet(pretrained=True, ctx=ctx) |
所设定层的学习率变为 base_learning_rate * params.lr_mult
梯度截断
1 | gluon.Trainer(net.collect_params(), 'sgd', {'lr': 1e-2, 'grad_clip': 2}) |
MXNet
API
reshape
1 | mxnet.ndarray.reshape(data=None, shape=_Null, reverse=_Null, target_shape=_Null, keep_highest=_Null, out=None, name=None, **kwargs) |
Debug
1 | 错误提示: |
1 | 错误提示: |