{"action":"created","issue":{"url":"https://api.github.com/repos/apache/incubator-mxnet/issues/12425","repository_url":"https://api.github.com/repos/apache/incubator-mxnet","labels_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/12425/labels{/name}","comments_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/12425/comments","events_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/12425/events","html_url":"https://github.com/apache/incubator-mxnet/issues/12425","id":356046035,"node_id":"MDU6SXNzdWUzNTYwNDYwMzU=","number":12425,"title":"Problem with Symbol.reshape and special value -2  [scala]","user":{"login":"mdespriee","id":1590580,"node_id":"MDQ6VXNlcjE1OTA1ODA=","avatar_url":"https://avatars2.githubusercontent.com/u/1590580?v=4","gravatar_id":"","url":"https://api.github.com/users/mdespriee","html_url":"https://github.com/mdespriee","followers_url":"https://api.github.com/users/mdespriee/followers","following_url":"https://api.github.com/users/mdespriee/following{/other_user}","gists_url":"https://api.github.com/users/mdespriee/gists{/gist_id}","starred_url":"https://api.github.com/users/mdespriee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdespriee/subscriptions","organizations_url":"https://api.github.com/users/mdespriee/orgs","repos_url":"https://api.github.com/users/mdespriee/repos","events_url":"https://api.github.com/users/mdespriee/events{/privacy}","received_events_url":"https://api.github.com/users/mdespriee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-31T16:26:15Z","updated_at":"2018-09-02T19:57:49Z","closed_at":null,"author_association":"NONE","body":"## Description\r\nI want to add an axis to an input, so I try to use Symbol.reshape with arg shape=(1, -2), but it fails with a cryptic message. Is there any workaround ?\r\n\r\n## Environment info (Required)\r\n- Linux setup using  https://raw.githubusercontent.com/apache/incubator-mxnet/1.2.1/ci/docker/install/ubuntu_core.sh (actually in a Docker)\r\n- MXNet 1.2.1, scala 2.11.11\r\n\r\n## Error Message:\r\n```\r\n[error] (run-main-0) org.apache.mxnet.MXNetError: Error in operator reshape0: [16:14:49] src/operator/tensor/./matrix_op-inl.h:187: Check failed: oshape.Size() == dshape.Size() (2 vs. 4) Target shape size is different to source. Target: [1,2]\r\n[error] Source: [2,2]\r\n[error]\r\n[error] Stack trace returned 10 entries:\r\n[error] [bt] (0) /tmp/mxnet2259072593884902973/mxnet-scala(dmlc::StackTrace[abi:cxx11]()+0x1bc) [0x7f705d82c4fc]\r\n[error] [bt] (1) /tmp/mxnet2259072593884902973/mxnet-scala(dmlc::LogMessageFatal::~LogMessageFatal()+0x28) [0x7f705d82d718]\r\n[error] [bt] (2) /tmp/mxnet2259072593884902973/mxnet-scala(mxnet::op::ReshapeShape(nnvm::NodeAttrs const&, std::vector<nnvm::TShape, std::allocator<nnvm::TShape> >*, std::vector<nnvm::TShape, std::allocator<nnvm::TShape> >*)+0xa1c) [0x7f705df3886c]\r\n[error] [bt] (3) /tmp/mxnet2259072593884902973/mxnet-scala(+0x20b0d61) [0x7f705f481d61]\r\n[error] [bt] (4) /tmp/mxnet2259072593884902973/mxnet-scala(mxnet::exec::InferShape(nnvm::Graph&&, std::vector<nnvm::TShape, std::allocator<nnvm::TShape> >&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x1a7f) [0x7f705f483ebf]\r\n[error] [bt] (5) /tmp/mxnet2259072593884902973/mxnet-scala(mxnet::exec::GraphExecutor::Init(nnvm::Symbol, mxnet::Context const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, mxnet::Context, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mxnet::Context> > > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, mxnet::Executor*, std::unordered_map<nnvm::NodeEntry, mxnet::NDArray, nnvm::NodeEntryHash, nnvm::NodeEntryEqual, std::allocator<std::pair<nnvm::NodeEntry const, mxnet::NDArray> > > const&)+0x10ed) [0x7f705f461f3d]\r\n[error] [bt] (6) /tmp/mxnet2259072593884902973/mxnet-scala(mxnet::Executor::Bind(nnvm::Symbol, mxnet::Context const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, mxnet::Context, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mxnet::Context> > > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> > const&, mxnet::Executor*)+0xe0) [0x7f705f463510]\r\n\r\n(...)\r\n[error] \tat org.apache.mxnet.Base$.checkCall(Base.scala:131)\r\n[error] \tat org.apache.mxnet.Symbol.bindHelper(Symbol.scala:786)\r\n[error] \tat org.apache.mxnet.Symbol.bind(Symbol.scala:711)\r\n[error] \tat ReshapeTest$.delayedEndpoint$ReshapeTest$1(tt.scala:72)\r\n[error] \tat ReshapeTest$delayedInit$body.apply(tt.scala:67)\r\n[error] \tat scala.Function0$class.apply$mcV$sp(Function0.scala:34)\r\n[error] \tat scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)\r\n[error] \tat scala.App$$anonfun$main$1.apply(App.scala:76)\r\n[error] \tat scala.App$$anonfun$main$1.apply(App.scala:76)\r\n[error] \tat scala.collection.immutable.List.foreach(List.scala:392)\r\n[error] \tat scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)\r\n[error] \tat scala.App$class.main(App.scala:76)\r\n[error] \tat ReshapeTest$.main(tt.scala:67)\r\n[error] \tat ReshapeTest.main(tt.scala)\r\n```\r\n\r\n## Minimum reproducible example\r\n```scala\r\nimport org.apache.mxnet._\r\n\r\nval a = Symbol.Variable(\"a\")\r\nval r = Symbol.reshape()(a)(Map(\"shape\" -> (1,-2)))\r\n\r\nval exec = r.bind(Context.defaultCtx, Map(\r\n    \"a\" -> NDArray.array(Array(1, 2, 3, 4), Shape(2,2))\r\n))\r\nexec.forward()\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/apache/incubator-mxnet/issues/comments/417955834","html_url":"https://github.com/apache/incubator-mxnet/issues/12425#issuecomment-417955834","issue_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/12425","id":417955834,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzk1NTgzNA==","user":{"login":"lanking520","id":11890922,"node_id":"MDQ6VXNlcjExODkwOTIy","avatar_url":"https://avatars0.githubusercontent.com/u/11890922?v=4","gravatar_id":"","url":"https://api.github.com/users/lanking520","html_url":"https://github.com/lanking520","followers_url":"https://api.github.com/users/lanking520/followers","following_url":"https://api.github.com/users/lanking520/following{/other_user}","gists_url":"https://api.github.com/users/lanking520/gists{/gist_id}","starred_url":"https://api.github.com/users/lanking520/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lanking520/subscriptions","organizations_url":"https://api.github.com/users/lanking520/orgs","repos_url":"https://api.github.com/users/lanking520/repos","events_url":"https://api.github.com/users/lanking520/events{/privacy}","received_events_url":"https://api.github.com/users/lanking520/received_events","type":"User","site_admin":false},"created_at":"2018-09-02T19:57:49Z","updated_at":"2018-09-02T19:57:49Z","author_association":"CONTRIBUTOR","body":"@mdespriee firstly the problem mentioned in the log means the shape of the data changed and there maybe data missing. As explained in [here](http://mxnet.apache.org/api/python/ndarray/ndarray.html#mxnet.ndarray.NDArray.reshape), users should not try to reshape the data with loss of data. However, I can use python to do the same thing without any issues:\r\n```Python\r\nimport mxnet as mx\r\na = mx.nd.array([[1,2],[3,4]])\r\nb = a.reshape(1, -2)\r\n>>> b\r\n[[1. 2.]]\r\n<NDArray 1x2 @cpu(0)>\r\n```\r\nNot sure what is the issue here, will look into it and see....\r\n@mxnet-label-bot please label [scala, bug]"}}
{"actor":{"display_login":"lanking520"}}