Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Mismatched Shapes in Value Error #12676

Closed
ChaiBapchya opened this issue Sep 26, 2018 · 6 comments
Closed

Mismatched Shapes in Value Error #12676

ChaiBapchya opened this issue Sep 26, 2018 · 6 comments
Labels

Comments

@ChaiBapchya
Copy link
Contributor

ChaiBapchya commented Sep 26, 2018

Description

Shapes given in the Value error seem to be mismatched between expected and got

Python

Compiler: visual studio

MXNet commit hash: 769165b

Error Message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bapac/workspace/incubator-mxnet/python/mxnet/ndarray/utils.py", line 146, in array
    return _array(source_array, ctx=ctx, dtype=dtype)
  File "/Users/bapac/workspace/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 2489, in array
    arr[:] = source_array
  File "/Users/bapac/workspace/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 444, in __setitem__
    self._set_nd_basic_indexing(key, value)
  File "/Users/bapac/workspace/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 710, in _set_nd_basic_indexing
    self._sync_copyfrom(value)
  File "/Users/bapac/workspace/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 872, in _sync_copyfrom
    str(self.shape), str(source_array.shape)))
ValueError: Shape inconsistent: expected () vs got (1,)

Minimum reproducible example

mx.nd.array(1)

Correct way of initialization right now is to feed a list,

>>> a=mx.nd.array([1])
>>> a

[1.]
<NDArray 1 @cpu(0)>

Shape of such an NDarray is

>>> a.shape
(1,)

Meaning, it expects (1,)
However, when we feed ()
It should give error

ValueError: Shape inconsistent: expected (1,) vs got ()

@vandanavk
Copy link
Contributor

@mxnet-label-bot [NDArray]

@ChaiBapchya
Copy link
Contributor Author

@mxnet-label-bot [Bug]

@vandanavk
Copy link
Contributor

Fix in PR #12678 (Ref: #12677 (comment))

@vrakesh
Copy link
Contributor

vrakesh commented Oct 8, 2018

@ChaiBapchya can this be closed as well?

@ChaiBapchya
Copy link
Contributor Author

Um, the PR doesn't address it and the question is still unanswered. I personally think it's mismatched. But wanted to confirm it. In that case, it's a simple change for PR.

@zhreshold
Copy link
Member

Yep, the order is wrong, could you open a PR to fix it, since the last conversation is closed. @ChaiBapchya

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants