static public TensorShape Reduce(this TensorShape shape, int axis) { axis = shape.Axis(axis); var newShapeArray = shape; newShapeArray[axis] = 1; return(newShapeArray); }
/// <summary> /// Reduce TensorShape across specified `axis` /// </summary> /// <param name="shape">TensorShape</param> /// <param name="axis">axis</param> /// <returns>output shape</returns> static public TensorShape Reduce(this TensorShape shape, int axis) { if (!shape.hasNamedDimensions) { shape = shape.AsNamed(); } axis = shape.Axis(axis); var newShapeArray = shape; newShapeArray[axis] = 1; return(newShapeArray); }
/// <summary> /// Allow to use negative axis to access tensorShape backward. /// `axis` should be from -rank to rank (exclusive). /// </summary> public int Axis(int axis) { return(shape.Axis(axis)); }