We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am getting this error while writing the following class code. The error message is attached below the code.
class GPReviewDataset(data.dataset):
def init(self, review, target, tokenizer, max_len): self.review = review self.target = target self.tokenizer = tokenizer self.max_len = max_len
def len(self): # return the number of reviews we have return len(self.reviews)
def getitem(self, item): # takes the index and the reviews review = str(self.reviews[item])
encoding = self.tokenizer.encode_plus( review, add_special_tokens=True, max_length=self.max_len, return_token_type_ids=False, pad_to_max_length=True, return_attention_mask=True, return_tensors='pt' ) return { 'review_text': review, 'input_ids': encoding['input_ids'].flatten(), 'attention_mask': encoding['attention_mask'].flatten(), 'targets': torch.tensor(self.target, dtype=torch.long) }
The text was updated successfully, but these errors were encountered:
for those who are facing this error as you code while watching the video, the solution is as follows -
class GPReviewDataset(data.dataset): -> change 'data.dataset' to 'Dataset' -> change is already made in the code but not in the video
In the create dataloader function write return DataLoader instead of return data.DataLoader
Thanks.
Sorry, something went wrong.
No branches or pull requests
I am getting this error while writing the following class code. The error message is attached below the code.
class GPReviewDataset(data.dataset):
def init(self, review, target, tokenizer, max_len):
self.review = review
self.target = target
self.tokenizer = tokenizer
self.max_len = max_len
def len(self):
# return the number of reviews we have
return len(self.reviews)
def getitem(self, item): # takes the index and the reviews
review = str(self.reviews[item])
The text was updated successfully, but these errors were encountered: