def __call__(self, x, t, train=True, finetune=False):
# First conv layer
h = self[0](x)
# Residual blocks
for i in range(1, len(self) - 2):
h = self[i](h, train, finetune)
# BN, relu, pool, final layer
h = self[-2](h)
h = F.relu(h)
n, nc, ns, nx, ny = h.data.shape
h = F.reshape(h, (n, nc * ns, nx, ny))
h = F.average_pooling_2d(h, ksize=h.data.shape[2:])
h = self[-1](h)
h = F.reshape(h, h.data.shape[:2])
return F.softmax_cross_entropy(h, t), F.accuracy(h, t)
评论列表
文章目录