nddl.py 文件源码

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

项目:ndparse 作者: neurodata 项目源码 文件源码
def number_classes(Yin, omitLabels=[]):
    """Remaps class labels to contiguous natural numbers starting at 0.
    In many frameworks (e.g. caffe) class labels are mapped to indices at
    the output of the CNN; hence this remapping.

    Any pixels that should be ignored will have class label of -1.
    """
    if Yin is None: return None

    yAll = np.sort(np.unique(Yin))
    yAll = [y for y in yAll if y not in omitLabels]

    Yout = -1*np.ones(Yin.shape, dtype=Yin.dtype)
    for yIdx, y in enumerate(yAll):
        Yout[Yin==y] = yIdx

    return Yout
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号