label.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:cebl 作者: idfah 项目源码 文件源码
def indicatorsFromVector(vector, nCls=None, conf=1.0):
    dtype = np.result_type(vector.dtype, np.float32)

    if nCls is None:
        nCls = np.max(vector)+1

    labels = np.arange(nCls, dtype=dtype)
    indicators = np.ones((len(vector), len(labels)), dtype=dtype)
    indicators = ((indicators*vector[:,None]) == (indicators*labels))

    offset = (1.0 - conf) / (nCls-1)
    indicators = indicators * (conf-offset) + offset

    return indicators.astype(dtype, copy=False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号