You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/05/01 03:42:14 UTC
[GitHub] [incubator-mxnet] roywei commented on a change in pull request
#14849: [Fit API] update estimator
roywei commented on a change in pull request #14849: [Fit API] update estimator
URL: https://github.com/apache/incubator-mxnet/pull/14849#discussion_r280000300
##########
File path: python/mxnet/gluon/contrib/estimator/estimator.py
##########
@@ -88,12 +88,17 @@ def _check_metrics(self, metrics):
return metrics
def _check_context(self, context):
- # handle context
- if isinstance(context, Context):
- context = [context]
- elif isinstance(context, list) and all([isinstance(c, Context) for c in context]):
- context = context
- elif not context:
+ if context:
+ # check context values, only accept Context or a list of Context
+ if isinstance(context, Context):
+ context = [context]
+ elif isinstance(context, list) and all([isinstance(c, Context) for c in context]):
+ context = context
Review comment:
How about:
```
available_context = [mx.gpu(i) for i in range(num_gpus)]
assert ctx in available_context or str(ctx).startswith('cpu')
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services