在关于reshape()函数的numpy手册中,它说
>>> a = np.zeros((10, 2))
# A transpose make the array non-contiguous
>>> b = a.T
# Taking a view makes it possible to modify the shape without modifying the
# initial object.
>>> c = b.view()
>>> c.shape = (20)
AttributeError: incompatible shape for a non-contiguous array
Run Code Online (Sandbox Code Playgroud)
我的问题是:
c.shape = (20)抛出错误incompatible shape for a non-contiguous array?感谢您的回答!
从Numpy的教程中,轴可以用整数编制索引,就像0用于列,1用于行,但我不明白为什么它们以这种方式编入索引?在处理多维数组时,如何计算每个轴的索引?
我还没有理解numpy中多维数组中的轴之间的差异。你能解释一下吗?我特别想知道numpy三维数组中的axis0,axis1和axis2在哪里。又为什么呢?谢谢。
np.transpose的时间复杂度是多少?
在我看来,它在内部循环了两个for循环,这意味着它应该具有O(n2)复杂度,但有人可以对此进行确认吗?另外,有什么办法可以减少矩阵转置的时间复杂度