shenweichen / DeepCTR

Easy-to-use,Modular and Extendible package of deep-learning based CTR models .
https://deepctr-doc.readthedocs.io/en/latest/index.html
Apache License 2.0
7.57k stars 2.21k forks source link

如何正确运行example中的程序? #262

Closed robinren03 closed 4 years ago

robinren03 commented 4 years ago

运行环境:

当执行python examples/run_classification_criteo.py 时,出现以下报错: image 请问如何处理?

michael0905 commented 4 years ago

deepfm的实现有bug,计算linear_logit的时候修改了feature_column的embedding_dim,导致embedding matrix前后shape不一致

def get_linear_logit(features, feature_columns, units=1, use_bias=False, seed=1024, prefix='linear',
                     l2_reg=0):
    linear_feature_columns = copy(feature_columns)
    for i in range(len(linear_feature_columns)):
        if isinstance(linear_feature_columns[i], SparseFeat):
            linear_feature_columns[i] = linear_feature_columns[i]._replace(embedding_dim=1)
        if isinstance(linear_feature_columns[i], VarLenSparseFeat):
            linear_feature_columns[i] = linear_feature_columns[i]._replace(
                sparsefeat=linear_feature_columns[i].sparsefeat._replace(embedding_dim=1))

在deepfm.py里把linear_logit去掉就可以运行了,linear层没有特征交叉,对深度模型本来贡献就很小