You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@mxnet.apache.org by Larry via MXNet Forum <mx...@discoursemail.com.INVALID> on 2021/01/07 14:30:39 UTC
[MXNet Forum] [Gluon] I fail to get an accuracy of more than 99%
This is the code that I had
def train(net, loss_fn, train_data, epochs, batch_size):
train_acc= metric.Accuracy()
trainer= gluon.Trainer(net.collect_params(),
'sgd',{'learning_rate': 0.1})
for epoch in range(2):
train_loss = 0
for data, label in train_data:
with autograd.record():
output = net(data)
loss = loss_fn(output, label)
loss.backward()
trainer.step(batch_size)
train_loss += loss.mean().asscalar()
train_acc.update(label, output)
print("Epoch [%d] Loss:%.3f Acc:%.3f"%(
epoch, train_loss/len(train_data),
train_acc.get()[1]))
net.save_parameters('trained_net.params')
return train_data, train_acc.get()[1]
We are supposed to train for 5 epochs and achieve an accuracy of over 99%
net, ta = train(*get_network(), train_data, 5, batch_size)
The image showed that the accuracy has topped off at 98.8%, which obviously failed to surpass 99%. Plus, the training stopped at epoch[2] instead of epoch[4]
![image|690x274](upload://779G8SLu17PAXfwZTOKYkqJSfgK.jpeg)
I must have made an error somewhere, but failed to locate that error. Need someone to point out the error
---
[Visit Topic](https://discuss.mxnet.apache.org/t/i-fail-to-get-an-accuracy-of-more-than-99/6814/1) or reply to this email to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.mxnet.apache.org/email/unsubscribe/2912740b12772c3fb5ba80aba09c258d708ad587590e86f9fee14070f29d488d).
[MXNet Forum] [Gluon] I fail to get an accuracy of more than 99%
Posted by Amir Ramezani via MXNet Forum <mx...@discoursemail.com.INVALID>.
hi,
try setting your learning rate to 0.001 or a smaller value and check how it performs
try adam instead of sgd and check the result.
you should play with hyper parameters to get the result that you need.
---
[Visit Topic](https://discuss.mxnet.apache.org/t/i-fail-to-get-an-accuracy-of-more-than-99/6814/2) or reply to this email to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.mxnet.apache.org/email/unsubscribe/8f7b9ae32161e81aae6ff0db8a764d152646655d1d00d58c9b6be91e5276e9e7).