janelu9 commented on issue #8065: Help? when I go on training a language model, 
errors occured
URL: 
https://github.com/apache/incubator-mxnet/issues/8065#issuecomment-332729914
 
 
   import mxnet as mx
   #mx.symbol_doc.SymbolDoc.get_output_shape()
   def N_gamma(seq_len,batch_size,vocab_size,embed_dim,hidden_num,N):    
       data = mx.sym.Variable('data')
       embed_weight=mx.sym.Variable('embed_weight')
       H_weight=mx.sym.Variable('H_weight')
       d_bias=mx.sym.Variable('d_bias')
       U_weight=mx.sym.Variable('U_weight')
       W_weight=mx.sym.Variable('W_weight')
       b_bias=mx.sym.Variable('b_bias')
       b0_bias=mx.sym.Variable('b0_bias')
       label = mx.sym.Variable('softmax_label')
       embed = mx.sym.Embedding(data=data, input_dim=vocab_size, 
weight=embed_weight,output_dim=embed_dim, name='embed')
       wordvec = 
mx.sym.SliceChannel(data=embed,num_outputs=seq_len+N-1,squeeze_axis=1)
       y_all=[]
       for seq_idx in range(N-1,seq_len+N-1):
           word=[wordvec[i] for i in xrange(seq_idx-N+1,seq_idx+1)]
           hidden_concat = mx.sym.Concat(*word, dim=1)
           
tanh_hidden=mx.sym.FullyConnected(data=hidden_concat,num_hidden=hidden_num,weight=H_weight,bias=d_bias,name='tanh_hidden')
           tanh_act=mx.sym.Activation(data=tanh_hidden, act_type="tanh")
           
tanh_part=mx.sym.FullyConnected(data=tanh_act,num_hidden=vocab_size,weight=U_weight,bias=b_bias,name='tanh_part')
           
fc_part=mx.sym.FullyConnected(data=hidden_concat,num_hidden=vocab_size,weight=W_weight,bias=b0_bias,name='fc_part')
           y=tanh_part+fc_part
           y_all.append(y)
       y_concat=mx.sym.Concat(*y_all,dim=0)
       label = mx.sym.transpose(data=label)
       label = mx.sym.Reshape(data=label, target_shape=(0,))
       sm = mx.sym.SoftmaxOutput(data=y_concat, label=label, name='softmax')
       return sm
 
----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to