Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The number of grammar rules (94) is inconsistent with the pre-trained model (97) #25

Open
lzw-pku opened this issue Nov 29, 2021 · 1 comment

Comments

@lzw-pku
Copy link

lzw-pku commented Nov 29, 2021

I find that the number of the grammar rules is 94 when I follow the instructions to preprocess the data (with the hyper-parameter fs=2). But the size of rule_embedding in the pre-trained model is 97.

Traceback (most recent call last):
File "run.py", line 104, in
main()
File "run.py", line 83, in main
infer.main(infer_config)
File "/home/yuhao/zhenwen/repair_model/gap-text2sql-main/rat-sql-gap/seq2struct/commands/infer.py", line 239, in main
model = inferer.load_model(args.logdir, args.step)
File "/home/yuhao/zhenwen/repair_model/gap-text2sql-main/rat-sql-gap/seq2struct/commands/infer.py", line 48, in load_model
last_step = saver.restore(logdir, step=step, map_location=self.device, item_keys=["model"])
File "/home/yuhao/zhenwen/repair_model/gap-text2sql-main/rat-sql-gap/seq2struct/utils/saver.py", line 122, in restore
items2restore, model_dir, map_location, step)
File "/home/yuhao/zhenwen/repair_model/gap-text2sql-main/rat-sql-gap/seq2struct/utils/saver.py", line 40, in load_checkpoint
item_dict[item_name].load_state_dict(checkpoint[item_name])
File "/home/yuhao/.conda/envs/zhenwen/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1407, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for EncDecModel:
Unexpected key(s) in state_dict: "decoder.state_update._input_dropout_mask", "decoder.state_update._h_dropout_mask".
size mismatch for decoder.rule_logits.2.weight: copying a param with shape torch.Size([97, 128]) from checkpoint, the shape in current model is torch.Size([94, 128]).
size mismatch for decoder.rule_logits.2.bias: copying a param with shape torch.Size([97]) from checkpoint, the shape in current model is torch.Size([94]).
size mismatch for decoder.rule_embedding.weight: copying a param with shape torch.Size([97, 128]) from checkpoint, the shape in current model is torch.Size([94, 128])

@fduzhuruisi
Copy link

Can you solve this problem? I had the same problem like yours:

Traceback (most recent call last):
File "run.py", line 104, in
main()
File "run.py", line 66, in main
train.main(train_config)
File "/home/zrs/gap-text2sql/rat-sql-gap/seq2struct/commands/train.py", line 270, in main
trainer.train(config, modeldir=args.logdir)
File "/home/zrs/gap-text2sql/rat-sql-gap/seq2struct/commands/train.py", line 135, in train
last_step = saver.restore(modeldir, map_location=self.device)
File "/home/zrs/gap-text2sql/rat-sql-gap/seq2struct/utils/saver.py", line 122, in restore
items2restore, model_dir, map_location, step)
File "/home/zrs/gap-text2sql/rat-sql-gap/seq2struct/utils/saver.py", line 40, in load_checkpoint
item_dict[item_name].load_state_dict(checkpoint[item_name], False)
File "/home/zrs/anaconda3/envs/gap-text2sql/lib/python3.7/site-packages/torch/nn/modules/module.py", line 847, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for EncDecModel:
size mismatch for encoder.question_encoder.0.embedding.weight: copying a param with shape torch.Size([1580, 300]) from checkpoint, the shape in current model is torch.Size([164, 300]).
size mismatch for encoder.column_encoder.0.embedding.weight: copying a param with shape torch.Size([1580, 300]) from checkpoint, the shape in current model is torch.Size([164, 300]).
size mismatch for encoder.table_encoder.0.embedding.weight: copying a param with shape torch.Size([1580, 300]) from checkpoint, the shape in current model is torch.Size([164, 300]).
size mismatch for decoder.rule_logits.2.weight: copying a param with shape torch.Size([97, 128]) from checkpoint, the shape in current model is torch.Size([75, 128]).
size mismatch for decoder.rule_logits.2.bias: copying a param with shape torch.Size([97]) from checkpoint, the shape in current model is torch.Size([75]).
size mismatch for decoder.rule_embedding.weight: copying a param with shape torch.Size([97, 128]) from checkpoint, the shape in current model is torch.Size([75, 128]).
size mismatch for decoder.node_type_embedding.weight: copying a param with shape torch.Size([55, 64]) from checkpoint, the shape in current model is torch.Size([49, 64]).

Looking forward to the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants