Click here to Skip to main content
15,919,245 members

Comments by Linlin Zeng (Top 5 by date)

Linlin Zeng 21-Jul-21 5:25am View    
okay; I found when running :
'''
TEXT.vocab.vectors.size()
'''
--> torch.Size([4, 300])
since the size should be 479 * 300; maybe I build a wrong vocab?
Linlin Zeng 21-Jul-21 5:23am View    
Sorry for misunderstanding your reply; I am using following packages;

'''import spacy
import pandas as pd
from torchtext.legacy.data import Field, TabularDataset, BucketIterator, LabelField
from sklearn.model_selection import train_test_split
from torchtext.vocab import GloVe'''

for batch in dataset_iter:
batch.text[0]
batch.term_index[0]
it suppose to print:
torchtext.data.batch.Batch of size 10
.text torch.cuda.LongTensor of size 104*10
.term_index torch.cuda.LongTensor of size 104*10;
just tell the batch can be run successfully

Linlin Zeng 21-Jul-21 5:03am View    
TEXT.vocab.vectors.size() # torch.Size([4, 300])
I suppose when building vocab, there is something wrong
'''
import spacy
import pandas as pd
from torchtext.legacy.data import Field, TabularDataset, BucketIterator, LabelField
from sklearn.model_selection import train_test_split
from torchtext.vocab import GloVe
'''
This is all packages I used; not import bird
Linlin Zeng 21-Jul-21 3:50am View    
oh; actually, it is more helpful if you can tell me how to modify it
Linlin Zeng 21-Jul-21 3:48am View    
dataset_iter = Iterator(
train, batch_size=10,
train=True, shuffle= True)
here dataset_iter is an iteration of train after using batch size; train is a tabular dataset after using Field to transfer word into tensors.