factorgraph.py 文件源码

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

项目:py-factorgraph 作者: mbforbes 项目源码 文件源码
def divide_safezero(a, b):
    '''
    Divies a by b, then turns nans and infs into 0, so all division by 0
    becomes 0.

    Args:
        a (np.ndarray)
        b (np.ndarray|int|float)

    Returns:
        np.ndarray
    '''
    # deal with divide-by-zero: turn x/0 (inf) into 0, and turn 0/0 (nan) into
    # 0.
    c = a / b
    c[c == np.inf] = 0.0
    c = np.nan_to_num(c)
    return c


# Classes
# -----------------------------------------------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号