feature.py 文件源码

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

项目:extract 作者: dblalock 项目源码 文件源码
def preprocessFeatureMat(X, Lfilt):
    """
    Binarizes and blurs the feature matrix

    Parameters
    ----------
    X : 2D array
        The original feature matrix (presumably output by buildFeatureMat())
    Lfilt : int
        The width of the hamming filter used to blur the feature matrix.

    Returns
    -------
    X : 2D array
        The modified feature matrix without blur
    Xblur : 2D array
        The modified feature matrix with blur
    """
    Xblur = _filterRows(X, Lfilt)

    # ensure that the maximum value in Xblur is 1; we do this by dividing
    # by the largets value within Lfilt / 2, rather than just clamping, so
    # that there's a smooth dropoff as you move away from dense groups of
    # 1s in X; otherwise it basically ends up max-pooled
    maxima = filters.maximum_filter1d(Xblur, Lfilt // 2, axis=1, mode='constant')
    Xblur[maxima > 0] /= maxima[maxima > 0]

    # have columns be adjacent in memory
    return np.asfortranarray(X), np.asfortranarray(Xblur)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号