CodeSage icon indicating copy to clipboard operation
CodeSage copied to clipboard

defect prediction task error

Open skye95git opened this issue 1 year ago • 1 comments

Hi, I try to run the defect prediction source code, there is an error: numpy.AxisError: axis 1 is out of bounds for array of dimension 1. How to fix it?

skye95git avatar Mar 25 '24 07:03 skye95git

Can you please paste the entire error log? We are unable to reproduce the error.

[Update] We were able to reproduce the error.

  File "/home/ec2-user/CodeSage/evaluation/defect_prediction.py", line 174, in <module>
    main()
  File "/home/ec2-user/CodeSage/evaluation/defect_prediction.py", line 161, in main
    trainer.train()
  File "/home/ec2-user/anaconda3/envs/codesage_eval/lib/python3.10/site-packages/transformers/trainer.py", line 1662, in train
    return inner_training_loop(
  File "/home/ec2-user/anaconda3/envs/codesage_eval/lib/python3.10/site-packages/transformers/trainer.py", line 2020, in _inner_training_loop
    self.control = self.callback_handler.on_epoch_end(args, self.state, self.control)
  File "/home/ec2-user/anaconda3/envs/codesage_eval/lib/python3.10/site-packages/transformers/trainer_callback.py", line 363, in on_epoch_end
    return self.call_event("on_epoch_end", args, state, control)
  File "/home/ec2-user/anaconda3/envs/codesage_eval/lib/python3.10/site-packages/transformers/trainer_callback.py", line 397, in call_event
    result = getattr(callback, event)(
  File "/home/ec2-user/CodeSage/evaluation/defect_prediction.py", line 87, in on_epoch_end
    self._trainer.evaluate(
  File "/home/ec2-user/anaconda3/envs/codesage_eval/lib/python3.10/site-packages/transformers/trainer.py", line 2993, in evaluate
    output = eval_loop(
  File "/home/ec2-user/anaconda3/envs/codesage_eval/lib/python3.10/site-packages/transformers/trainer.py", line 3281, in evaluation_loop
    metrics = self.compute_metrics(EvalPrediction(predictions=all_preds, label_ids=all_labels))
  File "/home/ec2-user/CodeSage/evaluation/defect_prediction.py", line 73, in compute_metrics
    predictions = np.argmax(predictions, axis=1)
  File "/home/ec2-user/anaconda3/envs/codesage_eval/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 1229, in argmax
    return _wrapfunc(a, 'argmax', axis=axis, out=out, **kwds)
  File "/home/ec2-user/anaconda3/envs/codesage_eval/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 59, in _wrapfunc
    return bound(*args, **kwds)
numpy.exceptions.AxisError: axis 1 is out of bounds for array of dimension 1

We are working on fixing the issue.

wasiahmad avatar May 23 '24 23:05 wasiahmad