You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the function evaluate_accuracy that appears in various examples in the tutorial is written in a suboptimal way, e.g. from deep conv nets:
defevaluate_accuracy(data_iterator, net):
acc=mx.metric.Accuracy()
ford, lindata_iterator:
data=d.as_in_context(ctx)
label=l.as_in_context(ctx) # This is unnecessaryoutput=net(data)
predictions=nd.argmax(output, axis=1)
acc.update(preds=predictions, labels=label)
returnacc.get()[1]
Usually in the examples, ctx refers to mx.gpu(), however within the definition ofmx.metric.Accuracy
we see that both predictions and labels are transformed to numpy arrays (i.e. copies to mx.cpu() context). Therefore, if ctx = mx.gpu() this function definition has unnecessary copies of labels into gpu memory and drops performance.
Thank you for the awesome tutorial you've created!
Regards
The text was updated successfully, but these errors were encountered:
Dear all,
the function
evaluate_accuracy
that appears in various examples in the tutorial is written in a suboptimal way, e.g. from deep conv nets:Usually in the examples, ctx refers to
mx.gpu()
, however within the definition ofmx.metric.Accuracy
we see that both predictions and labels are transformed to numpy arrays (i.e. copies to
mx.cpu()
context). Therefore, ifctx = mx.gpu()
this function definition has unnecessary copies of labels into gpu memory and drops performance.Thank you for the awesome tutorial you've created!
Regards
The text was updated successfully, but these errors were encountered: