NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

I apologize for the confusion. If you're getting a `KeyError: 'input_question'`, it means that the dictionary returned by the `collate_fn` doesn't have the key `'input_question'`. This might be because you're trying to access `'input_question'` key within your training loop.

Since we're using a different key `'combined_sequence'` in the `collate_fn`, you need to access that key instead. Here's how you should modify your training loop:

```python
# Training loop
num_epochs = 10
for epoch in range(num_epochs):
model.train()
total_loss = 0.0

for batch in tqdm(train_loader, desc=f"Epoch {epoch + 1}"):
combined_sequence = batch['combined_sequence'].to(device) # Use 'combined_sequence' key

optimizer.zero_grad()
output = model(combined_sequence, combined_sequence) # Use the same sequence for both input and target
output_dim = output.shape[-1]
output = output.contiguous().view(-1, output_dim)
target_sequence = combined_sequence.view(-1) # Flatten the target

loss = criterion(output, target_sequence)
loss.backward()
optimizer.step()

total_loss += loss.item()

avg_loss = total_loss / len(train_loader)
print(f"Epoch {epoch + 1}, Loss: {avg_loss:.4f}")
```

Make sure to use the key `'combined_sequence'` in your training loop instead of `'input_question'`.
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.