qkaren / unsup_gen_for_cms_reasoning

49 stars 13 forks source link

run_counterfactual_main.sh AttributeError: 'NoneType' object has no attribute 'shape' #2

Closed AdaCheng closed 3 years ago

AdaCheng commented 3 years ago

Environment info

To reproduce

Steps to reproduce the behavior:

  1. install test_data.json in TimeTravel Dataset
  2. replaced with the data path to test_data.json
  3. run the code in run_counterfactual_main.sh
#!/bin/bash

for num_passes in 5 10
do
  for num_backward_iters in 5 8 10 15
  do
    CUDA_VISIBLE_DEVICES=0 python3 counterfactual_main.py \
        --pretrained_model gpt2-medium \
        --mix_rate 0.92 \
        --temperature_forward 1 \
        --top_k 1 \
        --stepsize 0.0004 \
        --num_backward_iters ${num_backward_iters} \
        --num_passes ${num_passes} \
        --input_file ./data/counterfactual/test_data.json \
        --output_dir ./output/counterfactual/
  done
done

Error message:

100%|#################################################################################################################| 5/5 [00:03<00:00,  1.40it/s]
100%|#################################################################################################################| 5/5 [00:03<00:00,  1.51it/s]
100%|#################################################################################################################| 5/5 [00:03<00:00,  1.65it/s]
100%|#################################################################################################################| 5/5 [00:05<00:00,  1.02s/it]
 20%|######################6                                                                                          | 1/5 [00:00<00:01,  2.86it/s]
Traceback (most recent call last):
  File "counterfactual_main.py", line 542, in <module>
    verbose=args.verbose)
  File "counterfactual_main.py", line 154, in generate_counterfactual_story_endings
    verbose=verbose
  File "counterfactual_main.py", line 241, in delorean_decoding
    verbose=verbose
  File "counterfactual_main.py", line 343, in backward_pass
    grad_accumulator = [(np.zeros(p.shape).astype("float32")) for p in logits]
  File "counterfactual_main.py", line 343, in <listcomp>
    grad_accumulator = [(np.zeros(p.shape).astype("float32")) for p in logits]
AttributeError: 'NoneType' object has no attribute 'shape'
AdaCheng commented 3 years ago

Hi, I have found that this error is caused by the third sentence is NULL. I am wondering how you dealt with this problem? filtering them or? BTW, where is your evaluate.py, could you please offer it? Thanks!

qkaren commented 3 years ago

Hi,

Were you able to run the script https://github.com/qkaren/unsup_gen_for_cms_reasoning/blob/master/run_counterfactual_main.sh fine with the example data https://github.com/qkaren/unsup_gen_for_cms_reasoning/blob/master/data/counterfactual/small_data.json ?

On Thu, Dec 31, 2020 at 10:19 PM AdaCheng notifications@github.com wrote:

Hi, I have found that this error is caused by the third sentence is NULL. I am wondering how you dealt with this problem? filtering them or? BTW, where is your evaluate.py, could you please offer it? Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/qkaren/unsup_gen_for_cms_reasoning/issues/2#issuecomment-753268840, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIYQ5366KR5EICIVAHSA7DSXVSOTANCNFSM4VDCVYPQ .

AdaCheng commented 3 years ago

Hi, Were you able to run the script https://github.com/qkaren/unsup_gen_for_cms_reasoning/blob/master/run_counterfactual_main.sh fine with the example data https://github.com/qkaren/unsup_gen_for_cms_reasoning/blob/master/data/counterfactual/small_data.json ? On Thu, Dec 31, 2020 at 10:19 PM AdaCheng @.**> wrote: Hi, I have found that this error is caused by the third sentence is NULL. I am wondering how you dealt with this problem? filtering them or? BTW, where is your evaluate.py*, could you please offer it? Thanks! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#2 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIYQ5366KR5EICIVAHSA7DSXVSOTANCNFSM4VDCVYPQ .

Yes, I have already tested that I could run this example data. And this program also worded for most data in test_data.json. However, while the original endings split into three sentences, and the last sentence is "", this bug came out.

qkaren commented 3 years ago

could you send that example? usually, the original endings consist of 3 sentence

On Fri, Jan 1, 2021 at 10:03 PM AdaCheng notifications@github.com wrote:

Hi, Were you able to run the script https://github.com/qkaren/unsup_gen_for_cms_reasoning/blob/master/run_counterfactual_main.sh fine with the example data https://github.com/qkaren/unsup_gen_for_cms_reasoning/blob/master/data/counterfactual/small_data.json ? … <#m-2780859117536805988> On Thu, Dec 31, 2020 at 10:19 PM AdaCheng @.**> wrote: Hi, I have found that this error is caused by the third sentence is NULL. I am wondering how you dealt with this problem? filtering them or? BTW, where is your evaluate.py*, could you please offer it? Thanks! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#2 (comment) https://github.com/qkaren/unsup_gen_for_cms_reasoning/issues/2#issuecomment-753268840>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIYQ5366KR5EICIVAHSA7DSXVSOTANCNFSM4VDCVYPQ .

Yes, I have already tested that I could run this example data. And this program also worded for most data in test_data.json. However, while the original endings split into three sentences, and the last sentence is "", this bug came out.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/qkaren/unsup_gen_for_cms_reasoning/issues/2#issuecomment-753436906, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIYQ53IO5RDPPNQNT3V67DSX2ZKXANCNFSM4VDCVYPQ .

AdaCheng commented 3 years ago

{"story_id": "adfc4099-d29d-45f2-8c7d-da2bc2682d4f", "premise": "Dave decided one day he wanted to go see a hockey game.", "initial": "He ordered a few tickets.", "counterfactual": "He ordered a live stream of the game.", "original_ending": "He then invited some of his friends. They all went to the game, and had a good time Dave was happy that he went to the hockey game.", "edited_endings": [["He then invited some of his friends over.", "They all watched the game and had a good time.", "Dave was happy that they watched the hockey game."], ["He then invited some of his friends.", "They all watched the game, and had a good time", "Dave was happy that he watched the hockey game."], ["He didn't invite anyone because he likes watching alone.", "He went to the game and had a good time.", "Dave was happy that he went to the hockey game."]]}

Such as this one.

the __extract_a_sentence(text) module in counterfactual_main.py_ would convert this "original_ending" into three sentences: ["He then invited some of his friends.", "They all went to the game, and had a good time Dave was happy that he went to the hockey game.", ""]

qkaren commented 3 years ago

you can just add one "." to the original ending (Before "Dave")

He then invited some of his friends. They all went to the game, and had a good time. Dave was happy that he went to the hockey game.

On Fri, Jan 1, 2021 at 10:19 PM AdaCheng notifications@github.com wrote:

{"story_id": "adfc4099-d29d-45f2-8c7d-da2bc2682d4f", "premise": "Dave decided one day he wanted to go see a hockey game.", "initial": "He ordered a few tickets.", "counterfactual": "He ordered a live stream of the game.", "original_ending": "He then invited some of his friends. They all went to the game, and had a good time Dave was happy that he went to the hockey game.", "edited_endings": [["He then invited some of his friends over.", "They all watched the game and had a good time.", "Dave was happy that they watched the hockey game."], ["He then invited some of his friends.", "They all watched the game, and had a good time", "Dave was happy that he watched the hockey game."], ["He didn't invite anyone because he likes watching alone.", "He went to the game and had a good time.", "Dave was happy that he went to the hockey game."]]}

Such as this one.

the _extract_a_sentence(text) module in counterfactual_main.py would convert this "original_ending" into three sentences: ["He then invited some of his friends.", "They all went to the game, and had a good time Dave was happy that he went to the hockey game.", ""]

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/qkaren/unsup_gen_for_cms_reasoning/issues/2#issuecomment-753438078, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIYQ56527CDBU44G4RP74DSX23HBANCNFSM4VDCVYPQ .

AdaCheng commented 3 years ago

I get it. Thanks a lot for your reply. Happy New Year.