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))
评论列表
文章目录