expand_dims
扩展数组的形状,通过在由 axis
指定的位置插入一个大小为一的新轴(维度)。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
a
|
COO
|
输入的 COO 数组。 |
必需 |
axis
|
int
|
新轴在扩展后的轴中的放置位置。 |
0
|
返回值
名称 | 类型 | 描述 |
---|---|---|
result |
COO
|
一个具有与 |
示例
>>> import sparse
>>> x = sparse.COO.from_numpy([[1, 0, 0, 0, 2, -3]])
>>> x.shape
(1, 6)
>>> y1 = sparse.expand_dims(x, axis=1)
>>> y1.shape
(1, 1, 6)
>>> y2 = sparse.expand_dims(x, axis=2)
>>> y2.shape
(1, 6, 1)
源代码位于 sparse/numba_backend/_coo/common.py
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 |
|