Skip to content

ZeroDivisionError when reduction is set to 'wmean' while training iPET #103

@xruifan

Description

@xruifan

I ran the code with:

python cli.py \
  --method ipet \
  --data_dir ../dataset/data \
  --model_type bert \
  --model_name_or_path bert-base-cased \
  --task_name my-task \
  --output_dir ./bert_ipet_10_test \
  --pattern_ids 0 1 2 \
  --do_train \
  --do_eval \
  --eval_set test \
  --train_examples 10 \
  --unlabeled_examples 50 \
  --pet_max_seq_length 512 \
  --pet_repetitions 1 \
  --lm_training \
  --pet_per_gpu_train_batch_size 1 \
  --pet_per_gpu_eval_batch_size 1 \
  --pet_per_gpu_unlabeled_batch_size 1 \
  --pet_gradient_accumulation_steps 1 \
  --pet_num_train_epochs 3 \
  --pet_max_steps 25 \
  --sc_per_gpu_train_batch_size 1 \
  --sc_per_gpu_eval_batch_size 1 \
  --sc_per_gpu_unlabeled_batch_size 1 \
  --sc_gradient_accumulation_steps 1 \
  --sc_max_steps 100 \
  --sc_max_seq_length 512 \
  --ipet_generations 3 \
  --ipet_logits_percentage 0.25 \
  --ipet_scale_factor 4

The error occurred before preparing next-gen-train-data in the first generation g0 after conducting p0-i0, p1-i0, and p2-i0.

File "cli.py", line 282, in <module>
    main()
  File "cli.py", line 266, in main
    pet.train_ipet(pet_model_cfg, pet_train_cfg, pet_eval_cfg, ipet_cfg, sc_model_cfg, sc_train_cfg, sc_eval_cfg,
  File "C:\Users\uber\Desktop\2023\pet\pet\modeling.py", line 191, in train_ipet
    generate_ipet_train_sets(train_data=train_data, unlabeled_data=unlabeled_data,
  File "C:\Users\uber\Desktop\2023\pet\pet\modeling.py", line 683, in generate_ipet_train_sets
    subdir_train_set = generate_ipet_train_set(
  File "C:\Users\uber\Desktop\2023\pet\pet\modeling.py", line 727, in generate_ipet_train_set
    logits = np.average(logits, axis=0, weights=weights)
  File "<__array_function__ internals>", line 5, in average
  File "C:\Users\uber\.conda\envs\pet\lib\site-packages\numpy\lib\function_base.py", line 409, in average
    raise ZeroDivisionError(
ZeroDivisionError: Weights sum to zero, can't be normalized

It seems that my weights from this line:

weights = np.array([ll.score for ll in logits_lists])

is an empty array.

Any thoughts?

Regards,
Fan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions