model = ResNet(pretrained=True)
with dezero.test_mode():
y = model(x)
predict_id = np.argmax(y.data)
model.plot(x, to_file='ResNet152.pdf')
labels = dezero.datasets.ImageNet.labels()
print(labels[predict_id])
ここまで、
下記のようなエラーが出ます。
ここから、
Traceback (most recent call last):
File "step58_2.py", line 17, in
model = ResNet(pretrained=True)
File "../dezero/models.py", line 138, in init
self.res2 = BuildingBlock(block[0], 64, 64, 256, 1)
File "../dezero/models.py", line 196, in init
downsample_fb)
File "../dezero/models.py", line 236, in init
self.conv1 = L.Conv2d(in_channels, mid_channels, 1, stride_1x1, 0, nobias=True)
TypeError: init() got multiple values for argument ‘nobias'
ここまで、
エラーの内容を調べてみるとResNetの記述でのL.Conv2dの記述で、in_channelsを記述してしまっているためだとわかりました。
一応、下記の箇所を以下のように変更するとうまく動作してくれるようなのですが、この変更で問題ないでしょうか?
ここから、
p134 self.conv1 = L.Conv2d(3, 64, 7, 2, 3) -> self.conv1 = L.Conv2d(64, 7, 2, 3)
p223 self.conv1 = L.Conv2d(in_channels, mid_channels, 1, stride_1x1, 0, nobias=True) ->
self.conv1 = L.Conv2d(mid_channels, 1, stride_1x1, 0, nobias=True)
p226 self.conv2 = L.Conv2d(mid_channels, mid_channels, 3, stride_3x3, 1, nobias=True) ->
self.conv2 = L.Conv2d(mid_channels, 3, stride_3x3, 1, nobias=True)
p229 self.conv3 = L.Conv2d(mid_channels, out_channels, 1, 1, 0, nobias=True) ->
self.conv3 = L.Conv2d(out_channels, 1, 1, 0, nobias=True)
p231 self.conv4 = L.Conv2d(in_channels, out_channels, 1, stride, 0, nobias=True) ->
self.conv4 = L.Conv2d(out_channels, 1, stride, 0, nobias=True)
p253 self.conv1 = L.Conv2d(in_channels, mid_channels, 1, 1, 0, nobias=True) ->
self.conv1 = L.Conv2d(mid_channels, 1, 1, 0, nobias=True)
p255 self.conv2 = L.Conv2d(mid_channels, mid_channels, 3, 1, 1, nobias=True) ->
self.conv2 = L.Conv2d(mid_channels, 3, 1, 1, nobias=True)
p257 self.conv3 = L.Conv2d(mid_channels, in_channels, 1, 1, 0, nobias=True) ->
self.conv3 = L.Conv2d(in_channels, 1, 1, 0, nobias=True)
ここまで、
ご確認ください。