Repository: chainer/chainer

Issue:
A bug in loading pretrained model of ResNet 101
There is a bug in a code that  loads pretrained model for ResNet 101.

```python
>>> from chainer.links.model.vision.resnet import ResNet101Layers
>>> ResNet101Layers()

Now loading caffemodel (usually it may take few minutes)                                                              
Traceback (most recent call last):                                                                                    
  File "aaa.py", line 3, in <module>                                                                                  
    ResNet101Layers()                                                                                                 
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 354, in __init__                       
    super(ResNet101Layers, self).__init__(pretrained_model, 101)                                                      
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 109, in __init__                       
    pretrained_model, self)                                                                                           
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 682, in _retrieve                      
    lambda path: npz.load_npz(path, model))                                                                           
  File "/home/leus/install/chainer/chainer/dataset/download.py", line 151, in cache_or_load_file                      
    content = creator(temp_path)                                                                                      
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 681, in <lambda>                       
    path, lambda path: _make_npz(path, path_caffemodel, model, n_layers),                                             
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 668, in _make_npz                      
    path_caffemodel, path_npz, 101)                                                                                   
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 145, in convert_caffemodel_to_npz      
    _transfer_resnet101(caffemodel, chainermodel)                                                                     
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 631, in _transfer_resnet101            
    ['4a'] + ['4b'.format(i) for i in range(1, 23)])                                                                  
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 601, in _transfer_block                
    _transfer_bottleneckB(src, dst_bottleneckB, name)                                                                 
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 592, in _transfer_bottleneckB          
    _transfer_components(src, dst.conv1, dst.bn1, name, '2a')                                                         
  File "/home/leus/install/chainer/chainer/links/model/vision/resnet.py", line 574, in _transfer_components           
    src_conv = getattr(src, 'res{}_branch{}'.format(bname, cname))                                                    
AttributeError: 'CaffeFunction' object has no attribute 'res4b_branch2a'                                              

```



Discussion:

Resolving patch:
diff --git a/chainer/links/model/vision/resnet.py b/chainer/links/model/vision/resnet.py
--- a/chainer/links/model/vision/resnet.py
+++ b/chainer/links/model/vision/resnet.py
@@ -628,7 +628,7 @@ def _transfer_resnet101(src, dst):
     _transfer_block(src, dst.res2, ['2a', '2b', '2c'])
     _transfer_block(src, dst.res3, ['3a', '3b1', '3b2', '3b3'])
     _transfer_block(src, dst.res4,
-                    ['4a'] + ['4b'.format(i) for i in range(1, 23)])
+                    ['4a'] + ['4b{}'.format(i) for i in range(1, 23)])
     _transfer_block(src, dst.res5, ['5a', '5b', '5c'])
 
     dst.fc6.W.data[:] = src.fc1000.W.data


Test patch: