プリンキピア

第16章自然言語処理:応用

16.1.3. Creating Data Iterators16.1.3 データイテレータを作る

Now we can create data iterators. At each iteration, a minibatch of examples are returned.
英語のヒント
これでデータイテレータを作れる。各反復で、事例のミニバッチが返される。
train_iter = d2l.load_array((train_features, torch.tensor(train_data[1])), 64)

for X, y in train_iter:
    print('X:', X.shape, ', y:', y.shape)
    break
print('# batches:', len(train_iter))
X: torch.Size([64, 500]) , y: torch.Size([64])
# batches: 391