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

A BUG #295

Open
ODDHOOD opened this issue Aug 20, 2023 · 0 comments
Open

A BUG #295

ODDHOOD opened this issue Aug 20, 2023 · 0 comments

Comments

@ODDHOOD
Copy link

ODDHOOD commented Aug 20, 2023

for _ in train_iterator:
    local_steps = 0  # update step
    tr_loss = 0.0
    epoch_iterator = tqdm(train_dataloader, desc="Iteration", disable=False)
    step = 0  # backward step
    total_log_loss = 0
    model.train()
    for step, batch in enumerate(epoch_iterator):

        batch=batch.to(args.device)
    ------->    loss = model(batch)
        step += 1
        # loss=model(batch)
        total_log_loss += loss.mean().item()
        if args.gradient_accumulation_steps > 1:
            loss = loss / args.gradient_accumulation_steps
        loss.mean().backward()
        tr_loss += loss.mean().item()
        
 bug-detail:

File "prompt.py", line 9, in
main.main()
File "/home/jnu/zf/dstc11-track5/prompt/main.py", line 573, in main
loss = model(batch)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 171, in forward
outputs = self.parallel_apply(replicas, inputs, kwargs)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 181, in parallel_apply
return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 89, in parallel_apply
output.reraise()
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/_utils.py", line 644, in reraise
raise exception
TypeError: Caught TypeError in replica 0 on device 0.
Original Traceback (most recent call last):
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 64, in _worker
output = module(*input, **kwargs)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/openprompt/pipeline_base.py", line 449, in forward
return self._forward(*args, **kwargs)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/openprompt/pipeline_base.py", line 465, in _forward
outputs = self.prompt_model(batch)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/openprompt/pipeline_base.py", line 210, in forward
batch = self.template.process_batch(batch)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/openprompt/prompts/soft_template.py", line 94, in process_batch
inputs_embeds = self.raw_embedding(batch['input_ids'])
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/modules/sparse.py", line 162, in forward
return F.embedding(
File "/home/jnu/anaconda3/envs/zf/lib/python3.8/site-packages/torch/nn/functional.py", line 2210, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
TypeError: embedding(): argument 'indices' (position 2) must be Tensor, not tuple

how to solve it thanks

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

1 participant