def __call__(self, x, target, bf=False): y = self.glimpse_forward(x) if chainer.config.train: loss = F.softmax_cross_entropy(y, target) return loss else: y = F.softmax(y) index = xp.array(range(y.data.shape[0])) acc = y.data[index, target] acc = chainer.cuda.to_cpu(acc) return acc.sum()
def __call__(self, x, target): h = F.relu(self.norm_1_1(self.cnn_1_1(x))) h = F.relu(self.norm_1_2(F.max_pooling_2d(self.cnn_1_2(h), 2, stride=2))) h = F.relu(self.norm_2_1(self.cnn_2_1(h))) h = F.relu(self.norm_2_2(F.max_pooling_2d(self.cnn_2_2(h), 2, stride=2))) h = F.relu(self.norm_3_1(self.cnn_3_1(h))) h = F.relu(self.norm_3_2(self.cnn_3_2(h))) h = F.relu(self.norm_3_3(F.max_pooling_2d(self.cnn_3_3(h), 2, stride=2))) h = F.relu(self.norm_f1(self.full_1(h))) y = self.full_2(h) if chainer.config.train: loss = F.softmax_cross_entropy(y, target) return loss else: y = F.softmax(y) index = xp.array(range(y.data.shape[0])) acc = y.data[index, target] acc = chainer.cuda.to_cpu(acc) return acc.sum()