shenweichen/DeepCTR-Torch

RuntimeError: Sizes of tensors must match except in dimension 2.

qijunhui opened this issue · 1 comments

SparseFeat(_feature, data[_feature].nunique())的时候没有问题;
设置为SparseFeat(_feature, data[_feature].nunique(), embedding_dim="auto"),在fit的时候会报如下错误

Traceback (most recent call last):
  File "/root/qijunhui/eta-try-remote/deepfm/eta_train.py", line 94, in <module>
    model.fit(train_model_input, train[target].values, batch_size=1024, epochs=20, verbose=2, validation_split=0.2)
  File "/root/qijunhui/envs/eta-try/lib/python3.7/site-packages/deepctr_torch/models/basemodel.py", line 244, in fit
    y_pred = model(x).squeeze()
  File "/root/qijunhui/envs/eta-try/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/root/qijunhui/envs/eta-try/lib/python3.7/site-packages/deepctr_torch/models/deepfm.py", line 74, in forward
    fm_input = torch.cat(sparse_embedding_list, dim=1)
RuntimeError: Sizes of tensors must match except in dimension 2. Got 6 and 12 (The offending index is 0)

先问你两个问题,embedding_dim="auto"的原理是什么?适用于哪些模型?