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/03/28 03:22:07 UTC

[GitHub] [incubator-mxnet] windoman opened a new issue #14548: mx.viz.plot_network KeyError: 'ctc_loss0_output'

windoman opened a new issue #14548: mx.viz.plot_network KeyError: 'ctc_loss0_output'
URL: https://github.com/apache/incubator-mxnet/issues/14548
 
 
   ## Description
   
   I builded my network with `mx.sym.ctc_loss` for the final loss on speech recognition task, and with `mx.viz.plot_network` to make sure that the network have right struct. But I got an exception as invoking `mx.viz.plot_network`, even the symbol of network as simple as possible.
   
   ## Environment info (Required)
   
   operating system: ubuntu-16.04 LTS
   python version: python 3.5
   mxnet version: 1.4.0-cpu
   
   ## Error Message:
   
   ```
   Traceback (most recent call last):
     File "ctc_plot.py", line 21, in <module>
       mx.viz.plot_network(sym, shape=shape).view()
     File "/home/windog/.local/lib/python3.5/site-packages/mxnet/visualization.py", line 382, in plot_network
       shape = shape_dict[key][1:]
   KeyError: 'ctc_loss0_output'
   ```
   
   ## Minimum reproducible example
   (If you are using your own code, please provide a short script that reproduces the error. Otherwise, please provide link to the existing example.)
   
   **ctc_plot.py**:
   
   ``` python
   import mxnet as mx
   
   def ctc_sym():
       data = mx.sym.Variable('data')
       label = mx.sym.Variable('label')
       data_len = mx.sym.Variable('data_len')
       label_len = mx.sym.Variable('label_len')
   
       ctc_loss = mx.sym.ctc_loss(data, label, data_len, label_len, True, True)
       ctc_loss = mx.sym.MakeLoss(ctc_loss)
   
       return ctc_loss
   
   
   if __name__ == '__main__':
       shape = {'data': (400, 32, 100),   # [max_seq_len, batch_size, num_cls]
               'label': (32, 50),         # [batch_size, max_label_len]
               'data_len': (32,),         # [batch_size,]
               'label_len': (32,)}        # [batch_size,]
       sym = ctc_sym()
       mx.viz.plot_network(sym, shape=shape).view()
   ```
   
   ## Steps to reproduce
   (Paste the commands you ran that produced the error.)
   
   1. python3 ctc_plot.py
   
   ## What have you tried to solve it?
   
   1. there is a related issue: [#3221](https://github.com/apache/incubator-mxnet/issues/3221)
   2. I have debugged into `incubator-mxnet/python/mxnet/visualization.py` in which throw a exception, and got a wrong `key` for `shape_dict` in following position in `visualization.py`:
   
   ![image](https://user-images.githubusercontent.com/9418558/55126339-b56f2a00-5147-11e9-9bcc-1b9d46482598.png)
   
   And then, I found out that the input name of symbol of `MakeLoss(ctc_loss)`, `ctc_loss0_output0`, has a bit difference from `key = input_name + "_output"` which is `ctc_loss0_output`.  And shape variable `shape_dict` is given by following code in `visualization.py`:
   
   ![image](https://user-images.githubusercontent.com/9418558/55127050-ccaf1700-5149-11e9-962b-d3f90a63cebc.png)
   
   The definition of `list_outputs` which is located at line 734 of `mxnet/model/symbol.py`:
   
   ![image](https://user-images.githubusercontent.com/9418558/55127012-b012df00-5149-11e9-878b-0ae90fe83b9a.png)
   
   I could not deep into as its' low-level implement, so is there anyone to help me out. What raise that exception? Wrong invoking of `ctc_loss` or `plot_network`, or some inner mistakes in mxnet?

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