Movielens¶
- class paddle.text. Movielens ( data_file=None, mode='train', test_ratio=0.1, rand_seed=0, download=True ) [源代码] ¶
该类是对 Movielens 1-M 测试数据集的实现。
参数¶
返回值¶
Dataset
,Movielens 1-M 数据集实例。
代码示例¶
>>> import paddle
>>> from paddle.text.datasets import Movielens
>>> class SimpleNet(paddle.nn.Layer):
... def __init__(self):
... super().__init__()
...
... def forward(self, category, title, rating):
... return paddle.sum(category), paddle.sum(title), paddle.sum(rating)
>>> movielens = Movielens(mode='train')
>>> for i in range(10):
... category, title, rating = movielens[i][-3:]
... category = paddle.to_tensor(category)
... title = paddle.to_tensor(title)
... rating = paddle.to_tensor(rating)
...
... model = SimpleNet()
... category, title, rating = model(category, title, rating)
... print(category.shape, title.shape, rating.shape)
[] [] []
[] [] []
[] [] []
[] [] []
[] [] []
[] [] []
[] [] []
[] [] []
[] [] []
[] [] []