Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESMM模型预估cvr全为0 #16

Open
meilejw opened this issue Jan 2, 2020 · 7 comments
Open

ESMM模型预估cvr全为0 #16

meilejw opened this issue Jan 2, 2020 · 7 comments

Comments

@meilejw
Copy link

meilejw commented Jan 2, 2020

hi 请教个问题 ESMM模型预估的ctr看起来正常 但是预估cvr全为0 会是什么原因呢?

@jiwenbiao1
Copy link

请问哪里有数据集,直接可以用的

@fenxouxiaoquan
Copy link

fenxouxiaoquan commented Feb 27, 2020

hi 请教个问题 ESMM模型预估的ctr看起来正常 但是预估cvr全为0 会是什么原因呢?

我也遇到这个问题了,目前已解决,方式是:build_mode()函数只返回net,把计算logits的步骤放在my_model()函数里搞,

def my_model(features, labels, mode, params):
    with tf.variable_scope('ctr_model'):
        last_ctr_layer = build_mode(features, mode, params)
    with tf.variable_scope('cvr_model'):
        last_cvr_layer = build_mode(features, mode, params)
    
    head = head_lib._binary_logistic_or_multi_class_head(
            n_classes=2, weight_column=None, label_vocabulary=None,
            loss_reduction=losses.Reduction.SUM)
 
    ctr_logits = tf.layers.dense(last_ctr_layer, units=head.logits_dimension,
                                 kernel_initializer=tf.glorot_uniform_initializer())
    cvr_logits = tf.layers.dense(last_cvr_layer, units=head.logits_dimension,
                                 kernel_initializer=tf.glorot_uniform_initializer())

    ctr_predictions = tf.sigmoid(ctr_logits, name="CTR")
    cvr_predictions = tf.sigmoid(cvr_logits, name="CVR")
    .........

@ywc1026
Copy link

ywc1026 commented Jan 26, 2021

hi 请教个问题 ESMM模型预估的ctr看起来正常 但是预估cvr全为0 会是什么原因呢?

我也遇到这个问题了,目前已解决,方式是:build_mode()函数只返回net,把计算logits的步骤放在my_model()函数里搞,

def my_model(features, labels, mode, params):
    with tf.variable_scope('ctr_model'):
        last_ctr_layer = build_mode(features, mode, params)
    with tf.variable_scope('cvr_model'):
        last_cvr_layer = build_mode(features, mode, params)
    
    head = head_lib._binary_logistic_or_multi_class_head(
            n_classes=2, weight_column=None, label_vocabulary=None,
            loss_reduction=losses.Reduction.SUM)
 
    ctr_logits = tf.layers.dense(last_ctr_layer, units=head.logits_dimension,
                                 kernel_initializer=tf.glorot_uniform_initializer())
    cvr_logits = tf.layers.dense(last_cvr_layer, units=head.logits_dimension,
                                 kernel_initializer=tf.glorot_uniform_initializer())

    ctr_predictions = tf.sigmoid(ctr_logits, name="CTR")
    cvr_predictions = tf.sigmoid(cvr_logits, name="CVR")
    .........

我试了一下,CVR 还是 0

@ywc1026
Copy link

ywc1026 commented Jan 27, 2021

可能输入里没有 tfrecords 文件。把 train_input_fn 的函数第一句改成 dataset = tf.data.TFRecordDataset(filenames),然后 filename 里包含 tfrecords ,比如”../../cvr_train.tfrecords“ ,cvr 结果就不为 0

@shuDaoNan9
Copy link

可能输入里没有 tfrecords 文件。把 train_input_fn 的函数第一句改成 dataset = tf.data.TFRecordDataset(filenames),然后 filename 里包含 tfrecords ,比如”../../cvr_train.tfrecords“ ,cvr 结果就不为 0

你有数据集吗?

@ywc1026
Copy link

ywc1026 commented Feb 20, 2021

可能输入里没有 tfrecords 文件。把 train_input_fn 的函数第一句改成 dataset = tf.data.TFRecordDataset(filenames),然后 filename 里包含 tfrecords ,比如”../../cvr_train.tfrecords“ ,cvr 结果就不为 0

你有数据集吗?

我用的自己的数据集

@copypastejun
Copy link

hi 请教个问题 ESMM模型预估的ctr看起来正常 但是预估cvr全为0 会是什么原因呢?

我也遇到这个问题了,目前已解决,方式是:build_mode()函数只返回net,把计算logits的步骤放在my_model()函数里搞,

def my_model(features, labels, mode, params):
    with tf.variable_scope('ctr_model'):
        last_ctr_layer = build_mode(features, mode, params)
    with tf.variable_scope('cvr_model'):
        last_cvr_layer = build_mode(features, mode, params)
    
    head = head_lib._binary_logistic_or_multi_class_head(
            n_classes=2, weight_column=None, label_vocabulary=None,
            loss_reduction=losses.Reduction.SUM)
 
    ctr_logits = tf.layers.dense(last_ctr_layer, units=head.logits_dimension,
                                 kernel_initializer=tf.glorot_uniform_initializer())
    cvr_logits = tf.layers.dense(last_cvr_layer, units=head.logits_dimension,
                                 kernel_initializer=tf.glorot_uniform_initializer())

    ctr_predictions = tf.sigmoid(ctr_logits, name="CTR")
    cvr_predictions = tf.sigmoid(cvr_logits, name="CVR")
    .........

ctr_logits = tf.layers.dense(last_ctr_layer, units=head.logits_dimension,
kernel_initializer=tf.glorot_uniform_initializer())
cvr_logits = tf.layers.dense(last_cvr_layer, units=head.logits_dimension,
kernel_initializer=tf.glorot_uniform_initializer())

其中 head.logits_dimension 在做二分类的情况下 返回的就是 1,效果和 logits = tf.layers.dense(net, 1, activation=None)是一样的啊

@Property
def logits_dimension(self):
return 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants