utils_pos_axes.py 文件源码

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

项目:ngraph 作者: NervanaSystems 项目源码 文件源码
def make_pos_axis(length, pos, prefix=POS_AXIS_PREFIX):
    """
    Make positional Axis of length `length` and of position `pos`

    Args:
        length: the length of the Axis, can be None
        pos: position of the Axis

    Example:
        for a tensor of shape (4, 3), it's positional axes are:
        [make_pos_axis(4, 1), make_pos_axis(3, 1)]

    Returns:
        Axis object
    """
    if not (isinstance(pos, numbers.Integral) and pos >= 0):
        raise ValueError("pos {} must be integer greater or equal than zero."
                         .format(pos))
    return ng.make_axis(length, name='%s%s' % (prefix, pos))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号