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/06/07 17:30:14 UTC

[GitHub] spidyDev opened a new pull request #11189: Adding support for dict in infer_shape

spidyDev opened a new pull request #11189: Adding support for dict in  infer_shape
URL: https://github.com/apache/incubator-mxnet/pull/11189
 
 
   Currently in MXNET if I have below code, infer shape fails:
   
   ```
   data = mx.sym.Variable('data-gpu0')
   prev = mx.sym.Variable('prev')
   fc1  = mx.sym.FullyConnected(data=data, name='fc1', num_hidden=128)
   fc2  = mx.sym.FullyConnected(data=prev, name='fc2', num_hidden=128)
   out  = mx.sym.Activation(data=mx.sym.elemwise_add(fc1, fc2), act_type='relu')
   out.infer_shape(data-gpu0=(10,64), 'prev'=(10,128))
   
     File "<ipython-input-6-3834d8e9b880>", line 2
       out.infer_shape(data-gpu0=(10,64), 'prev'=(10,128))
   SyntaxError: keyword can't be an expression
   ```
   Also one cannot infer_shape using variable  as name  i.e
   ```
   data = mx.sym.Variable('data')
   prev = mx.sym.Variable('prev')
   fc1  = mx.sym.FullyConnected(data=data, name='fc1', num_hidden=128)
   fc2  = mx.sym.FullyConnected(data=prev, name='fc2', num_hidden=128)
   out  = mx.sym.Activation(data=mx.sym.elemwise_add(fc1, fc2), act_type='relu')
   name="data"
   out.infer_shape(name=(10,64), prev=(10,128))
   
   MXNetError: [10:24:51] src/c_api/c_api_symbolic.cc:422: InferShapeKeyword argument name name not found.
   Candidate arguments:
   	[0]data
   	[1]fc1_weight
   	[2]fc1_bias
   	[3]prev
   	[4]fc2_weight
   	[5]fc2_bias
   ```
   
   To solve this issue I propose solution in this PR to add support for infer_shape to accept dict, so that user can provide data_names and shapes freely.(This will also be similar to mx.viz.plot_network that takes inputs as dict)
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [ ] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant [JIRA issue](https://issues.apache.org/jira/projects/MXNET/issues) created (except PRs with tiny changes)
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage:
   - Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
   - Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
   - Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
   - [ ] Code is well-documented: 
   - For user-facing API changes, API doc string has been updated. 
   - For new C++ functions in header files, their functionalities and arguments are documented. 
   - For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
   - Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
   - [ ] To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [ ] Add infer_shape to accept "dict" of input names and shapes as key value pair.
   - [ ] Feature2, tests, (and when applicable, API doc)
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be made.
   - Interesting edge cases to note here
   

----------------------------------------------------------------
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