当前位置: 首页>>代码示例>>Python>>正文


Python cider_scorer.CiderScorer方法代码示例

本文整理汇总了Python中cider_scorer.CiderScorer方法的典型用法代码示例。如果您正苦于以下问题:Python cider_scorer.CiderScorer方法的具体用法?Python cider_scorer.CiderScorer怎么用?Python cider_scorer.CiderScorer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cider_scorer的用法示例。


在下文中一共展示了cider_scorer.CiderScorer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def __init__(self, n=4, df="corpus"):
        """
        Initialize the CIDEr scoring function
        : param n (int): n-gram size
        : param df (string): specifies where to get the IDF values from
                    takes values 'corpus', 'coco-train'
        : return: None
        """
        # set cider to sum over 1 to 4-grams
        self._n = n
        self._df = df
        self.cider_scorer = CiderScorer(n=self._n, df_mode=self._df) 
开发者ID:xiadingZ,项目名称:video-caption-openNMT.pytorch,代码行数:14,代码来源:cider.py

示例2: compute_score

# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
        """
        Main function to compute CIDEr score
        :param  hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
                ref_for_image (dict)  : dictionary with key <image> and value <tokenized reference sentence>
        :return: cider (float) : computed CIDEr score for the corpus 
        """

        assert(gts.keys() == res.keys())
        imgIds = gts.keys()

        cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)

        for id in imgIds:
            hypo = res[id]
            ref = gts[id]

            # Sanity check.
            assert(type(hypo) is list)
            assert(len(hypo) == 1)
            assert(type(ref) is list)
            assert(len(ref) > 0)

            cider_scorer += (hypo[0], ref)

        (score, scores) = cider_scorer.compute_score()

        return score, scores 
开发者ID:hadyelsahar,项目名称:Zeroshot-QuestionGeneration,代码行数:30,代码来源:cider.py

示例3: compute_score

# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
        """
        Main function to compute CIDEr score
        :param  hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
                ref_for_image (dict)  : dictionary with key <image> and value <tokenized reference sentence>
        :return: cider (float) : computed CIDEr score for the corpus
        """

        assert(set(gts.keys()) == set(res.keys()))
        imgIds = gts.keys()

        cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)

        for id in imgIds:
            hypo = res[id]
            ref = gts[id]

            # Sanity check.
            assert(type(hypo) is list)
            assert(len(hypo) == 1)
            assert(type(ref) is list)
            assert(len(ref) > 0)

            cider_scorer += (hypo[0], ref)

        (score, scores) = cider_scorer.compute_score()

        return score, scores 
开发者ID:danieljl,项目名称:keras-image-captioning,代码行数:30,代码来源:cider.py

示例4: compute_score

# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
        """
        Main function to compute CIDEr score
        :param  hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
                ref_for_image (dict)  : dictionary with key <image> and value <tokenized reference sentence>
        :return: cider (float) : computed CIDEr score for the corpus 
        """

        # assert(gts.keys() == res.keys())
        assert(sorted(gts.keys()) == sorted(res.keys()))
        imgIds = gts.keys()

        cider_scorer = CiderScorer(df=self.df, n=self._n, sigma=self._sigma)

        for id in imgIds:
            hypo = res[id]
            ref = gts[id]

            # Sanity check.
            assert(type(hypo) is list)
            assert(len(hypo) == 1)
            assert(type(ref) is list)
            assert(len(ref) > 0)

            cider_scorer += (hypo[0], ref)

        (score, scores) = cider_scorer.compute_score()

        return score, scores 
开发者ID:eric-xw,项目名称:AREL,代码行数:31,代码来源:cider.py

示例5: compute_score

# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
        """
        Main function to compute CIDEr score
        :param  hypo_for_image (dict) : dictionary with img_id <image> and value <tokenized hypothesis / candidate sentence>
                ref_for_image (dict)  : dictionary with img_id <image> and value <tokenized reference sentence>
        :return: cider (float) : computed CIDEr score for the corpus 
        """

        assert (gts.keys() == res.keys())
        imgIds = gts.keys()

        cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)

        for id in imgIds:
            hypo = res[id]
            ref = gts[id]

            # Sanity check.
            assert (type(hypo) is list)
            assert (len(hypo) == 1)
            assert (type(ref) is list)
            assert (len(ref) > 0)

            cider_scorer += (hypo[0], ref)

        (score, scores) = cider_scorer.compute_score()

        return score, scores 
开发者ID:sheffieldnlp,项目名称:deepQuest,代码行数:30,代码来源:cider.py

示例6: compute_score

# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
        """
        Main function to compute CIDEr score
        :param  hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
                ref_for_image (dict)  : dictionary with key <image> and value <tokenized reference sentence>
        :return: cider (float) : computed CIDEr score for the corpus 
        """

        #assert(gts.keys() == res.keys())
        assert(set(gts.keys()) == set(res.keys()))
        imgIds = gts.keys()

        cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)

        for id in imgIds:
            hypo = res[id]
            ref = gts[id]

            # Sanity check.
            assert(type(hypo) is list)
            assert(len(hypo) == 1)
            assert(type(ref) is list)
            assert(len(ref) > 0)

            cider_scorer += (hypo[0], ref)

        (score, scores) = cider_scorer.compute_score()

        return score, scores 
开发者ID:rakshithShetty,项目名称:captionGAN,代码行数:31,代码来源:cider.py

示例7: compute_score

# 需要导入模块: import cider_scorer [as 别名]
# 或者: from cider_scorer import CiderScorer [as 别名]
def compute_score(self, gts, res):
        """
        Main function to compute CIDEr score
        :param  hypo_for_image (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
                ref_for_image (dict)  : dictionary with key <image> and value <tokenized reference sentence>
        :return: cider (float) : computed CIDEr score for the corpus 
        """

        assert(sorted(gts.keys()) == sorted(res.keys()))
        imgIds = gts.keys()

        cider_scorer = CiderScorer(n=self._n, sigma=self._sigma)

        for id in imgIds:
            hypo = res[id]
            ref = gts[id]

            # Sanity check.
            assert(type(hypo) is list)
            assert(len(hypo) == 1)
            assert(type(ref) is list)
            assert(len(ref) > 0)

            cider_scorer += (hypo[0], ref)

        (score, scores) = cider_scorer.compute_score()

        return score, scores 
开发者ID:fukun07,项目名称:neural-image-captioning,代码行数:30,代码来源:cider.py


注:本文中的cider_scorer.CiderScorer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。