我收到一个奇怪的错误,代码如下:
import numpy as np
w=np.random.rand(100,10)
x=np.random.rand(200,100)
y= np.random.rand(200,10)
def compute( x, y):
numpy_x = np.array(x)
numpy_y = np.array(y)
zeross = np.zeros(np.shape(x)[0])
oness = np.ones(np.shape(x)[0])
result= np.zeros((np.shape(x)[0],np.shape(y)[1]))
for i in range(np.shape(x)[1]):
for j in range(np.shape(y)[1]):
result[i,j] = w[i,j]+np.max(zeross, np.subtract(oness,w[:,j].dot(np.transpose(numpy_x)))).dot(numpy_x[:,i]*(numpy_y[:,j]*-1))
return result
print(compute(x,y))
这里x
是100 by 100
矩阵,y
是100 by 5
矩阵{
Test Failed: only integer scalar arrays can be converted to a scalar index
编译器似乎指示错误在库中?在
^{pr2}$请帮忙
目前没有回答
相关问题 更多 >
编程相关推荐