小编Vip*_*tal的帖子

np.array.sum(-1) 中的 sum(-1) 是什么意思?

我刚刚开始使用 numpy。在进行分类时我遇到了np.ndarray.sum(-1)

像这样的代码

rand_arr = np.random.rand(10, 2)
differences = rand_arr[:, np.newaxis, :] - rand_arr[np.newaxis, :, :]
Run Code Online (Sandbox Code Playgroud)

所以差异是一个 3-D 矩阵shape (10,10,2)

现在他们正在使用这个命令 difference.sum(-1) # this will convert the 3-D matrix into 2-D matrix of shape (10,10)

那么这.sum(-1)到底意味着什么呢?

python numpy

3
推荐指数
1
解决办法
8220
查看次数

标签 统计

numpy ×1

python ×1