In [56]:
my_net = MLP()
serializers.load_npz('my_mnist.model', my_net)
In [57]:
train_iter = iterators.SerialIterator(train_val, batchsize)
x, t = concat_examples(train_iter.next(), gpu_id)
with chainer.using_config('train', False), chainer.using_config('enable_backprop', False):
y = net(x)
accuracy = F.accuracy(y, t)
print(accuracy.array)
In [59]:
x, t = test[random.randint(0, len(test))]
x = infer_net.xp.asarray(x[None, ...])
with chainer.using_config('train', False), chainer.using_config('enable_backprop', False):
y = infer_net(x)
y = y.array
print(y)
print(y.argmax(axis=1)[0], t)
コメント
コメントを投稿