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/10/18 12:13:47 UTC
[GitHub] soeque1 commented on issue #12844: ERROR parameter summary of lstm
layer
soeque1 commented on issue #12844: ERROR parameter summary of lstm layer
URL: https://github.com/apache/incubator-mxnet/issues/12844#issuecomment-430985305
Thanks for your help in solving this problem.
But, There are still some issues. This is not HybridSequential or Sequential.
```
import mxnet as mx
from mxnet import gluon
from mxnet.gluon import HybridBlock, nn, rnn
class MyModel(gluon.HybridBlock):
def __init__(self, vocab_size, num_embed, **kwargs):
super(MyModel, self).__init__(**kwargs)
with self.name_scope():
self.embed = nn.Embedding(input_dim=vocab_size, output_dim=num_embed)
self.lstm = rnn.LSTM(20)
self.out = nn.Dense(2)
def hybrid_forward(self, F ,inputs):
em_out = self.embed(inputs)
lstm_out = self.lstm(em_out)
return(self.out(lstm_out))
model = MyModel(vocab_size =20, num_embed=50)
model.initialize(mx.init.Xavier())
model.hybridize()
mx.viz.print_summary(
model(mx.sym.var('data')),
shape={'data':(1,30)}, #set your shape here
)
```
________________________________________________________________________________________________________________________
Layer (type) Output Shape Param # Previous Layer
========================================================================================================================
data(null) 30 0
________________________________________________________________________________________________________________________
mymodel3_embedding0_fwd(Embedding) 30x50 0 data
________________________________________________________________________________________________________________________
mymodel3_lstm0_reshape0(Reshape) 0
________________________________________________________________________________________________________________________
mymodel3_lstm0_reshape1(Reshape) 0
________________________________________________________________________________________________________________________
mymodel3_lstm0_reshape2(Reshape) 0
________________________________________________________________________________________________________________________
mymodel3_lstm0_reshape3(Reshape) 0
________________________________________________________________________________________________________________________
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-8-d83349ac28a7> in <module>
21 mx.viz.print_summary(
22 model(mx.sym.var('data')),
---> 23 shape={'data':(1,30)}, #set your shape here
24 )
~/python/venv/ngram_detectors/lib/python3.6/site-packages/mxnet/visualization.py in print_summary(symbol, shape, line_length, positions)
186 if key in shape_dict:
187 out_shape = shape_dict[key][1:]
--> 188 total_params += print_layer_summary(nodes[i], out_shape)
189 if i == len(nodes) - 1:
190 print('=' * line_length)
~/python/venv/ngram_detectors/lib/python3.6/site-packages/mxnet/visualization.py in print_layer_summary(node, out_shape)
132 if key in shape_dict:
133 shape = shape_dict[key][1:]
--> 134 pre_filter = pre_filter + int(shape[0])
135 cur_param = 0
136 if op == 'Convolution':
IndexError: tuple index out of range
```
----------------------------------------------------------------
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