I have a roberta-base
model to which I want to pass my inputs. Here is a code snippet:
with tqdm(train_loader, unit="train_batch", desc='Train') as tqdm_train_loader:
for step, batch in enumerate(tqdm_train_loader):
inputs = batch.pop("inputs")
labels = batch.pop("labels")
inputs = collate(inputs) # collate inputs
for k, v in inputs.items(): # send each tensor value to `device`
inputs[k] = v.to(device)
labels = labels.to(device) # send labels to `device`
batch_size = labels.size(0)
with torch.cuda.amp.autocast(enabled=config.APEX):
y_preds = model(inputs) # <--- problem is here
loss = criterion(y_preds, labels) # get loss
In my model definition, in the forward()
method I pass the input in this way:
outputs = self.model(**inputs)
I don’t know why this is causing trouble, other models work fine when passing the inputs this way.
This is the error:
804 raise ValueError("You have to specify either input_ids or inputs_embeds")
805
--> 806 batch_size, seq_length = input_shape
807 device = input_ids.device if input_ids is not None else inputs_embeds.device
808
ValueError: too many values to unpack (expected 2)
Any help is appreciated.