update
This commit is contained in:
@ -63,7 +63,7 @@ for t in range(100):
|
|||||||
pred_y = prediction.data.numpy().squeeze()
|
pred_y = prediction.data.numpy().squeeze()
|
||||||
target_y = y.data.numpy()
|
target_y = y.data.numpy()
|
||||||
plt.scatter(x.data.numpy()[:, 0], x.data.numpy()[:, 1], c=pred_y, s=100, lw=0, cmap='RdYlGn')
|
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 = sum(pred_y == target_y)/200.
|
||||||
plt.text(1.5, -4, 'Accuracy=%.2f' % accuracy, fontdict={'size': 20, 'color': 'red'})
|
plt.text(1.5, -4, 'Accuracy=%.2f' % accuracy, fontdict={'size': 20, 'color': 'red'})
|
||||||
plt.pause(0.1)
|
plt.pause(0.1)
|
||||||
|
|
||||||
|
|||||||
@ -98,7 +98,7 @@ for epoch in range(EPOCH):
|
|||||||
if step % 50 == 0:
|
if step % 50 == 0:
|
||||||
test_output = cnn(test_x)
|
test_output = cnn(test_x)
|
||||||
pred_y = torch.max(test_output, 1)[1].data.squeeze()
|
pred_y = torch.max(test_output, 1)[1].data.squeeze()
|
||||||
accuracy = sum(pred_y == test_y) / test_y.size(0)
|
accuracy = sum(pred_y == test_y) / float(test_y.size(0))
|
||||||
print('Epoch: ', epoch, '| train loss: %.4f' % loss.data[0], '| test accuracy: %.2f' % accuracy)
|
print('Epoch: ', epoch, '| train loss: %.4f' % loss.data[0], '| test accuracy: %.2f' % accuracy)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@ for epoch in range(EPOCH):
|
|||||||
if step % 50 == 0:
|
if step % 50 == 0:
|
||||||
test_output = rnn(test_x) # (samples, time_step, input_size)
|
test_output = rnn(test_x) # (samples, time_step, input_size)
|
||||||
pred_y = torch.max(test_output, 1)[1].data.numpy().squeeze()
|
pred_y = torch.max(test_output, 1)[1].data.numpy().squeeze()
|
||||||
accuracy = sum(pred_y == test_y) / test_y.size
|
accuracy = sum(pred_y == test_y) / float(test_y.size)
|
||||||
print('Epoch: ', epoch, '| train loss: %.4f' % loss.data[0], '| test accuracy: %.2f' % accuracy)
|
print('Epoch: ', epoch, '| train loss: %.4f' % loss.data[0], '| test accuracy: %.2f' % accuracy)
|
||||||
|
|
||||||
# print 10 predictions from test data
|
# print 10 predictions from test data
|
||||||
|
|||||||
Reference in New Issue
Block a user