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

5-NLP/14-Embeddings /EmbeddingsPyTorch.ipynb In[18] Errors may occur during operation #245

Open
mouseart opened this issue Sep 21, 2023 · 0 comments

Comments

@mouseart
Copy link

mouseart commented Sep 21, 2023

EmbeddingsPyTorch.ipynb

train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=16, collate_fn=offsetify, shuffle=True) train_epoch_emb(net,train_loader, lr=4, epoch_size=25000)

AttributeError Traceback (most recent call last)
/Users/mouseart/OneDrive/book/AI-For-Beginners-Code/lessons/5-NLP/14-Embeddings/EmbeddingsPyTorch.ipynb 单元格 37 line 2
1 train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=16, collate_fn=offsetify, shuffle=True)
----> 2 train_epoch_emb(net,train_loader, lr=4, epoch_size=25000)

/Users/mouseart/OneDrive/book/AI-For-Beginners-Code/lessons/5-NLP/14-Embeddings/EmbeddingsPyTorch.ipynb 单元格 37 line 8
6 net.train()
7 total_loss,acc,count,i = 0,0,0,0
----> 8 for labels,text,off in dataloader:
9 optimizer.zero_grad()
10 labels,text,off = labels.to(device), text.to(device), off.to(device)

File ~/.pyenv/versions/3.9.7/lib/python3.9/site-packages/torch/utils/data/dataloader.py:633, in _BaseDataLoaderIter.next(self)
630 if self._sampler_iter is None:
631 # TODO(pytorch/pytorch#76750)
632 self._reset() # type: ignore[call-arg]
--> 633 data = self._next_data()
634 self._num_yielded += 1
635 if self._dataset_kind == _DatasetKind.Iterable and
636 self._IterableDataset_len_called is not None and
637 self._num_yielded > self._IterableDataset_len_called:

File ~/.pyenv/versions/3.9.7/lib/python3.9/site-packages/torch/utils/data/dataloader.py:677, in _SingleProcessDataLoaderIter._next_data(self)
675 def _next_data(self):
...
---> 33 stoi = v.get_stoi()
34 stoi_hash[v]=stoi
35 return [stoi.get(s,unk) for s in tokenizer(x)]

AttributeError: 'GloVe' object has no attribute 'get_stoi'

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