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/04/14 20:33:20 UTC
[GitHub] [incubator-mxnet] fhieber opened a new issue #14695: tuple
unpacking inconsistent for symbol and ndarray namespaces
fhieber opened a new issue #14695: tuple unpacking inconsistent for symbol and ndarray namespaces
URL: https://github.com/apache/incubator-mxnet/issues/14695
Tuple unpacking for `mx.nd.array` seems strange:
```python
In [47]: a, b = mx.nd.ones((2,4))
In [48]: a
Out[48]:
[1. 1. 1. 1.]
<NDArray 4 @cpu(0)>
In [49]: b
Out[49]:
[1. 1. 1. 1.]
<NDArray 4 @cpu(0)>
In [50]: a.handle
Out[50]: c_void_p(140359605559680)
In [51]: b.handle
Out[51]: c_void_p(140359605605952)
```
For symbols it behaves as I would expect:
```python
In [52]: a, b = mx.sym.ones((2,4))
ValueError: not enough values to unpack (expected 2, got 1)
```
I have a use case where this is an issue:
```python
x, *l = mx.sym.split(mx.sym.Variable('x'), axis=2, num_outputs=1, squeeze_axis=True)
```
As expected `l` is `[]`.
For ndarrays:
```python
In [54]: x, *l = mx.nd.split(mx.nd.ones((2,4,1)), axis=2, num_outputs=1, squeeze_axis=True)
In [55]: x
Out[55]:
[1. 1. 1. 1.]
<NDArray 4 @cpu(0)>
In [56]: l
Out[56]:
[
[1. 1. 1. 1.]
<NDArray 4 @cpu(0)>]
```
This is problematic if writing HybridBlocks with that logic, as they behave differently when hybridized.
----------------------------------------------------------------
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