Closed Qian-Hao closed 4 years ago
@Qian-Hao
您好
可不可以告诉我您用的torch, numpy, prediction-flow的版本
print(numpy.__version__)
print(torch.__version__)
print(prediction_flow.__version__)
@Qian-Hao
您好
可不可以告诉我您用的torch, numpy, prediction-flow的版本
print(numpy.__version__) print(torch.__version__) print(prediction_flow.__version__)
numpy == 1.16.4 torch == 1.2.0 prediciton-flow我是直接在github上下载的源码,应该是最新版的吧
torch的embedding需要LongTensor https://pytorch.org/docs/stable/nn.html?highlight=embedding#torch.nn.Embedding
因为在我的机器上(mac10.15以及centos7)测试并没有问题,所以忘记做强制类型转换 https://github.com/GitHub-HongweiZhang/prediction-flow/blob/master/prediction_flow/pytorch/data/dataset.py#L48
可以告诉我您用的什么系统吗?
稍等,我今天下午把这部分改一下。
torch的embedding需要LongTensor https://pytorch.org/docs/stable/nn.html?highlight=embedding#torch.nn.Embedding
因为在我的机器上(mac10.15以及centos7�)测试并没有问题,所以忘记做强制类型转换 https://github.com/GitHub-HongweiZhang/prediction-flow/blob/master/prediction_flow/pytorch/data/dataset.py#L48
可以告诉我您用的什么系统吗?
稍等,我今天下午把这部分改一下。
我用的win10。我自己先试试修改一下,麻烦你了。
不客气 。谢谢提交bug
通过以下程序,可以查看数据的类型
for key, value in next(iter(train_loader)).items():
print(key, value.dtype)
这是我的输出
age torch.float32
gender torch.int64
movieId torch.int64
occupation torch.int64
zipCode torch.int64
genres torch.int64
__genres_length torch.int64
histHighRatedMovieIds torch.int64
__histHighRatedMovieIds_length torch.int64
negHistMovieIds torch.int64
__negHistMovieIds_length torch.int64
label torch.float32
这是我的输出 age torch.float32 gender torch.int32 movieId torch.int32 occupation torch.int32 zipCode torch.int32 genres torch.int32 genres_length torch.int64 histHighRatedMovieIds torch.int32 __histHighRatedMovieIds_length torch.int64 negHistMovieIds torch.int32 negHistMovieIds_length torch.int64 label torch.float32
从您的输出来看,应该是由于系统位数的原因。 而且只修改以下部分是不行的。 https://github.com/GitHub-HongweiZhang/prediction-flow/blob/master/prediction_flow/pytorch/data/dataset.py#L48
我下午在模型里面增加对embedding输入数据的类型转换
从您的输出来看,应该是由于系统位数的原因。 而且只修改以下部分是不行的。 https://github.com/GitHub-HongweiZhang/prediction-flow/blob/master/prediction_flow/pytorch/data/dataset.py#L48
我下午在模型里面增加对embedding输入数据的类型转换
我的电脑也是64位的
您好,我修复了上述问题。 https://github.com/GitHub-HongweiZhang/prediction-flow/pull/17
可以再尝试一下吗?
您好,我修复了上述问题。
17
可以再尝试一下吗?
可以运行了,感谢大佬。
执行movielens-1m.ipynb时报错 Traceback (most recent call last): File "D:/项目/CTR/prediction-flow/examples/movielens/movielens-1m.py", line 118, in
fit(10, model, loss_func, optimizer, train_loader, valid_loader, notebook=True, auxiliary_loss_rate=0.1)
File "D:\项目\CTR\prediction-flow\prediction_flow\pytorch\functions.py", line 57, in fit
pred = model(batch)
File "D:\Programs\Anaconda\envs\python3.6\lib\site-packages\torch\nn\modules\module.py", line 547, in call
result = self.forward(*input, *kwargs)
File "D:\项目\CTR\prediction-flow\prediction_flow\pytorch\interest_net.py", line 200, in forward
feature.name](x[feature.name])
File "D:\Programs\Anaconda\envs\python3.6\lib\site-packages\torch\nn\modules\module.py", line 547, in call
result = self.forward(input, kwargs)
File "D:\Programs\Anaconda\envs\python3.6\lib\site-packages\torch\nn\modules\sparse.py", line 114, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File "D:\Programs\Anaconda\envs\python3.6\lib\site-packages\torch\nn\functional.py", line 1467, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.cuda.IntTensor instead (while checking arguments for embedding)**