liumilan commented on issue #8500: program crash when run sparse model predict
URL: 
https://github.com/apache/incubator-mxnet/issues/8500#issuecomment-343683671
 
 
   Linear_classfication.py is also changed 
    # model
       # The positive class weight, says how much more we should upweight the 
importance of
       # positive instances in the objective function.
       # This is used to combat the extreme class imbalance.
       positive_class_weight = 2
       model = linear_model(num_features, positive_class_weight)
   
       # module
       mod = mx.mod.Module(symbol=model,data_names=['data'], 
label_names=['softmax_label'],context=devs)
       mod.bind(data_shapes=train_data.provide_data, 
label_shapes=train_data.provide_label)
       mod.init_params()
       optim = mx.optimizer.create(optimizer, learning_rate=0.7,momentum = 
0.8,rescale_grad=1.0/batch_size/num_worker)
       mod.init_optimizer(optimizer=optim, kvstore=kv)
       # use accuracy as the metric
       metric = mx.metric.create(['ce','auc'])
   
       # get the sparse weight parameter
       weight_index = mod._exec_group.param_names.index('weight')
       weight_param = mod._exec_group.param_arrays[weight_index]
       speedometer = mx.callback.Speedometer(batch_size, 100)
   
       mod.fit(train_data = train_data,
               eval_data = eval_data,
               eval_metric = metric,
               optimizer = optim,
               kvstore = kvstore,
               num_epoch = args.num_epoch,
               #batch_end_callback = mx.callback.Speedometer(batch_size, 10000),
               batch_end_callback = None,
               epoch_end_callback = save_model())
   

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to