Not enough values to unpack (expected 2, got 1)

Rexedoziem: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/f/5f62cae6232794c812b53d3a0363743a2e3044e1.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/5f62cae6232794c812b53d3a0363743a2e3044e1" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/5/f/5f62cae6232794c812b53d3a0363743a2e3044e1_2_375x500.jpeg" alt="image" data-base62-sha1="dBP1lP6Ch1cZTNoi3pfLWasIGcN" width="375" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/5/f/5f62cae6232794c812b53d3a0363743a2e3044e1_2_375x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/5/f/5f62cae6232794c812b53d3a0363743a2e3044e1_2_562x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/5/f/5f62cae6232794c812b53d3a0363743a2e3044e1_2_750x1000.jpeg 2x" data-dominant-color="A28A75"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1920×2560 555 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/d/1/d1bf3d092c794140735d92b188cd8bbd07b31cd4.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/d1bf3d092c794140735d92b188cd8bbd07b31cd4" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/d/1/d1bf3d092c794140735d92b188cd8bbd07b31cd4_2_375x500.jpeg" alt="image" data-base62-sha1="tVvw6eJ4rDh8Rm3NtHOTo9WaRGA" width="375" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/d/1/d1bf3d092c794140735d92b188cd8bbd07b31cd4_2_375x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/d/1/d1bf3d092c794140735d92b188cd8bbd07b31cd4_2_562x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/d/1/d1bf3d092c794140735d92b188cd8bbd07b31cd4_2_750x1000.jpeg 2x" data-dominant-color="99917C"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1920×2560 726 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>import torch.nn as nn<br>
import torch<br>
from transformers import DebertaModel, DebertaTokenizer<br>
import transformers</p>
<p>class DebertaModel(nn.Module):<br>
def <strong>init</strong>(self):<br>
super(DebertaModel, self).<strong>init</strong>()<br>
self.deberta = transformers.DebertaModel.from_pretrained(‘…/input/deberta/base’, return_dict=True)<br>
self.dropout = nn.Dropout(0.3)<br>
self.classified = nn.Linear(768, config.out_features)</p>
<pre><code>def forward(self, ids, mask, token_type_ids):
    _, pooled_output = self.deberta(
        input_ids = ids,
        attention_mask = mask,
        token_type_ids = token_type_ids)
    pooled_output = self.dropout(pooled_output)
    outputs = self.classified(pooled_output)

    return outputs
</code></pre>

Rexedoziem: <p>import torch.nn as nn<br>
from tqdm import tqdm<br>
import torch</p>
<p>def loss_fn(outputs, target):<br>
return nn.MSELoss()(outputs, target)</p>
<p>def train_fx(data_loader, model, optimizer, scheduler, device):<br>
model.train()</p>
<pre><code>train_loss = 0
for bi, d in tqdm(enumerate(data_loader)):
    ids = d['ids']
    mask = d['mask']
    token_type_ids = d['token_type_ids']
    target = d['targets']
# putting them into the device

    ids = ids.to(device, dtype=torch.long)
    mask = mask.to(device, dtype=torch.long)
    token_type_ids = token_type_ids.to(device, dtype=torch.long)
    target = target.to(device, dtype=torch.long)
        
    optimizer.zero_grad()
    outputs = model(
        ids = ids,
        mask = mask,
        token_type_ids = token_type_ids
    )
    
    loss = loss_fn(outputs, target)
    loss.backward()
    optimizer.step()
    scheduler.step()
    train_loss += loss.item()
    train_loss = train_loss / len(data_loader)
    
return train_loss
</code></pre>
<p>This is the issue from my model?</p>

ptrblck: <p>It’s unclear which line of code causes the issue but based on your screenshots it should be somewhere in <code>train_fx</code>.<br>
Posting screenshots and unformatted code makes debugging unnecessarily harder, so please format your code properly by wrapping it into three backticks ``` and don’t post screenshots.</p>

Rexedoziem: <h2>
<a name="h-0it-0002-its-1" class="anchor" href="#h-0it-0002-its-1"></a>0it [00:02, ?it/s]</h2>
<p>ValueError                                Traceback (most recent call last)<br>
/tmp/ipykernel_17/3018574526.py in <br>
2 best_accuracy = 0<br>
3 for epoch in range(config.EPOCHS):<br>
----&gt; 4     train_loss = train_fx(train_data_loader, model, optimizer,scheduler, device)<br>
5     outputs, target = eval_fx(valid_data_loader, model, device)<br>
6     accuracy = metrics.accuracy_score(outputs, targets)</p>
<p>/tmp/ipykernel_17/4220120316.py in train_fx(data_loader, model, optimizer, scheduler, device)<br>
28             ids = ids,<br>
29             mask = mask,<br>
—&gt; 30             token_type_ids = token_type_ids<br>
31         )<br>
32</p>
<p>/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)<br>
1108         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks<br>
1109                 or _global_forward_hooks or _global_forward_pre_hooks):<br>
 → 1110             return forward_call(*input, **kwargs)<br>
1111         # Do not call functions when jit is used<br>
1112         full_backward_hooks, non_full_backward_hooks = [], []</p>
<p>/tmp/ipykernel_17/2396469671.py in forward(self, ids, mask, token_type_ids)<br>
17             input_ids = ids,<br>
18             attention_mask = mask,<br>
—&gt; 19             token_type_ids = token_type_ids)<br>
20         pooled_output = self.dropout(pooled_output)<br>
21         outputs = self.classified(pooled_output)</p>
<p>ValueError: not enough values to unpack (expected 2, got 1)</p>

Rexedoziem: <p>Guess the error came from the model</p>