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

实体消歧训练时间 #5

Open
sleepsophia opened this issue Oct 12, 2019 · 5 comments
Open

实体消歧训练时间 #5

sleepsophia opened this issue Oct 12, 2019 · 5 comments

Comments

@sleepsophia
Copy link

请问实体消歧的训练,大约需要多久

@panchunguang
Copy link
Owner

panchunguang commented Oct 17, 2019 via email

@zhangyanbo2007
Copy link

本人基本跑通,有需要交流加我15821444815,谢谢!

@Lanme
Copy link

Lanme commented Mar 19, 2020

@panchunguang 实体消歧的训练,metric_f1=nan?应该是里面的pred_num=0

@Jonny-Smith-GitHub
Copy link

Jonny-Smith-GitHub commented Aug 14, 2020

@panchunguang 实体消歧的训练,metric_f1=nan?应该是里面的pred_num=0

您好,我也遇到了这个问题,找了一下代码,是metric_f1函数,但想请教一个问题:这个函数需要传两个参数y_pred和y_true,而在调用处,没有传参数就调用了,有点不太理解。

@YanqiangWang
Copy link

@panchunguang 实体消歧的训练,metric_f1=nan?应该是里面的pred_num=0

from keras import backend as K
def metrics_f1(y_true, y_pred):
    def recall(y_true, y_pred):
        """Recall metric.
        Only computes a batch-wise average of recall.
        Computes the recall, a metric for multi-label classification of
        how many relevant items are selected.
        """
        true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
        possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))
        recall = true_positives / (possible_positives + K.epsilon())
        return recall
 
    def precision(y_true, y_pred):
        """Precision metric.
        Only computes a batch-wise average of precision.
        Computes the precision, a metric for multi-label classification of
        how many selected items are relevant.
        """
        true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
        predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))
        precision = true_positives / (predicted_positives + K.epsilon())
        return precision
    precision = precision(y_true, y_pred)
    recall = recall(y_true, y_pred)
    return 2*((precision*recall)/(precision+recall+K.epsilon()))

使用这个代码计算f1值,把原代码中的metrics_f1方法替换掉,就不会出现nan的问题了

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