datasets.py 文件源码

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

项目:ADD-GAN 作者: zblasingame 项目源码 文件源码
def rescale(data, _min, _max, start=0.0, end=1.0, axis=0):
    """Rescale features of a dataset

    args:
        data (np.array): feature matrix.
        _min (np.array): list of minimum values per feature.
        _max (np.array): list of maximum values per feature.
        start (float = 0.): lowest value for norm.
        end (float = 1.): highest value for norm.
        axis (int = 0): axis to normalize across

    returns:
        (np.array): normalized features, the same shape as data
    """

    new_data = (data - _min) / (_max - _min)

    # check if feature is constant, will be nan in new_data
    np.place(new_data, np.isnan(new_data), 1)

    new_data = (end - start) * new_data + start

    return new_data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号