update accuracy function

This commit is contained in:
morvanzhou
2018-06-29 10:09:52 +08:00
parent 79380fb90e
commit f2ebd8a37b
3 changed files with 4 additions and 4 deletions

View File

@ -62,7 +62,7 @@ for t in range(100):
pred_y = prediction.data.numpy().squeeze()
target_y = y.data.numpy()
plt.scatter(x.data.numpy()[:, 0], x.data.numpy()[:, 1], c=pred_y, s=100, lw=0, cmap='RdYlGn')
accuracy = sum(pred_y == target_y)/200.
accuracy = float((pred_y == target_y).astype(int).sum()) / float(target_y.size)
plt.text(1.5, -4, 'Accuracy=%.2f' % accuracy, fontdict={'size': 20, 'color': 'red'})
plt.pause(0.1)