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 2018/08/18 06:24:23 UTC

[GitHub] zheng-da commented on a change in pull request #12209: Make the output format of foreach consistent with while_loop

zheng-da commented on a change in pull request #12209: Make the output format of foreach consistent with while_loop
URL: https://github.com/apache/incubator-mxnet/pull/12209#discussion_r211066717
 
 

 ##########
 File path: python/mxnet/ndarray/contrib.py
 ##########
 @@ -98,6 +98,39 @@ def rand_zipfian(true_classes, num_sampled, range_max, ctx=None):
     return sampled_classes, expected_count_true, expected_count_sampled
 # pylint: enable=line-too-long
 
+
+def _flatten(args, inout_str):
+    if isinstance(args, ndarray.NDArray):
+        return [args], int(0)
+
+    assert isinstance(args, (list, tuple)), \
+        "HybridBlock %s must be (nested) list of Symbol or NDArray, " \
+        "but got %s of type %s"%(inout_str, str(args), str(type(args)))
 
 Review comment:
   it didn't work. _regroup is fine, but _flatten requires both NDArray and Symbol. I tried to put it in utils.py, which causes utils.py to import NDArray and Symbol, while NDArray and Symbol need to copy utils.py. It's kind of weird to only keep _regroup in utils.py.
   Are there any better solutions?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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