3
我做SVD,當我嘗試運行我的代碼,我得到以下錯誤播出在一起:Python的ValueError異常:操作數無法與形狀
ValueError: operands could not be broadcast together with shapes (375, 375) (375, 500)
我使用的大小爲(500圖像,375 )
這裏是我的代碼:
from PIL import Image
from Image import new
from numpy import *
import numpy as np
from scipy.linalg import svd
im = Image.open("lake.tif")
pix = im.load()
im.show()
r, g, b = im.split()
R = np.array(r.getdata())
R.shape = (500, 375)
Ur, Sr, VrT = svd(R.T, full_matrices=False)
R1 = Ur * diag(Sr) * VrT
你可能應該描述如何將一個'ndarray'轉換成'matrix',並且解釋說對於'matrix'對象,乘法運作如預期的那樣... –