"W"행렬 배수 행렬 곱셈 (모든 곱셈은 열 벡터 결과)이 필요합니다.파이썬에서 반복적 인 곱하기에 "점"(또는 "matmul") 함수를 사용하는 방법
from numpy import matrix
from numpy import transpose
from numpy import matmul
from numpy import dot
# Iterative matrix multiplication
def iterativeMultiplication(X, Y):
W = [] # Matrix of matricial products
X = matrix(X) # same number of rows
Y = matrix(Y) # same number of rows
h = 0
while (h < X.shape[1]):
W.append([])
W[h] = dot(transpose(X), Y) # using "dot" function
h += 1
return W
그러나 예기치 않게 각 데이터 유형의 개체 목록을 얻습니다.
에X = [[0., 0., 1.], [1.,0.,0.], [2.,2.,2.], [2.,5.,4.]]
Y = [[-0.2], [1.1], [5.9], [12.3]] # Edit Y column
iterativeMultiplication(X, Y)
결과 : 매트릭스 변환만을 수치 값을 얻기 위해
[array([[37.5],[73.3],[60.8]]),
array([[37.5],[73.3],[60.8]]),
array([[37.5],[73.3],[60.8]])]
나는 임의의 방법이 필요하다.
W = matrix(W) # Results in error
"matmul"기능을 사용하는 경우와 동일합니다. 너의 시간 동안 Thx. 여러 행렬 스택하려면
이것은 유효한 Python 코드가 아닙니다. – hpaulj