janelu9 opened a new issue #8065: Help? when I go on training a language model, 
errors occured
URL: https://github.com/apache/incubator-mxnet/issues/8065
 
 
   my model:
   ```
   import mxnet as mx
   import numpy as np
   from word2vec_io import BucketSentenceIter
   import pickle as pk
   
   sym, arg_params, aux_params = mx.model.load_checkpoint('output/5_gram', 10)
   
   def Perplexity(label, pred):
       label = label.T.reshape((-1,))
       loss = 0.
       for i in range(pred.shape[0]):
           loss += -np.log(max(1e-10, pred[i][int(label[i])]))
       return np.exp(loss / label.size)
   
   N=5
   batch_size=64
   data=pk.load(open('.//data//train.pkl','r'))
   data=[i[0] for i in data]
   data_val=pk.load(open('.//data//test.pkl','r'))
   data_val=[i[0] for i in data_val]
   train=BucketSentenceIter(data,batch_size,N)
   val=BucketSentenceIter(data_val,batch_size,N)
   
   devs = [mx.gpu(i) for i in range(1)]
   mod = mx.mod.Module(symbol=sym, context=devs)
   mod.fit(train, val,
           num_epoch=8,
           arg_params=arg_params,
           aux_params=aux_params,
           epoch_end_callback=mx.callback.do_checkpoint("./output/5_2gram"),
            eval_metric = mx.metric.np(Perplexity))
   
   ```
 
----------------------------------------------------------------
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