首页 > 解决方案 > TypeError: order 必须是 str,而不是 int

问题描述

M = Train.shape[1]

Theta = np.zeros((120,M))
for k in range(M):
 temp = np.reshape(np.copy(Train[:,k]),(m,n))
 tempSmall = resize(temp, (10, 12), anti_aliasing=True)
 Theta[:,k] = np.reshape(tempSmall,120,1)

TypeError Traceback (最近一次调用最后) C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py in _wrapfunc(obj, method, *args, **kwds) 57 try: ---> 58 return bound(*args, **kwds) 59 除了 TypeError:

TypeError: order must be str, not int 在处理上述异常的过程中,又出现了一个异常:

完整追溯: https ://drive.google.com/file/d/1xJTVtDEl_boFGP2l2uv6WK0EeBCM1vfu/view ?usp=sharing

标签: pythonnumpy

解决方案


上面的代码是通过用这个语法改变最后一行代码来解决的

Theta[:,[k]] = np.reshape(tempSmall,(120,1))


推荐阅读