Best practice for predicting values from model with Chainer
<p>With <a href="http://chainer.org/" rel="nofollow">Chainer</a>, I have created <code>model.pkl</code> with <em>Iris Datasets</em> (<a href="https://github.com/silwyb/train-iris" rel="nofollow">https://github.com/silwyb/train-iris</a>). So I can evaluate datasets, but I don't know the best way to output predicted values. </p>

<p>Please tell me how to predict. Just a function name would also be welcome.</p>

<p>The following works.
<a href="https://github.com/silwyb/train-iris/blob/master/predict.py" rel="nofollow">silwyb/train-iris/predict.py</a></p>

<pre><code>def predict(x_test):
    x = Variable(x_test)

    h1 = F.dropout(F.relu(model.l1(x)))
    h2 = F.dropout(F.relu(model.l2(h1)))
    y = model.l3(h2)

    return np.argmax(y.data)
</code></pre>

python chainer