0

私は Python の初心者で、Python を使用して主成分分析 (PCA) を実装していますが、平均の計算に問題があります。これが私のコードです:

import Image
import os
from PIL import Image
from numpy import *
import numpy as np


#import images
dirname = "C:\\Users\\Karim\\Downloads\\att_faces\\New folder"
X = [np.asarray(Image.open(os.path.join(dirname, fn))) for fn in os.listdir(dirname)]

#get number of images and dimentions
path, dirs, files = os.walk(dirname).next()
num_images = len(files)
image_file = "C:\\Users\\Karim\\Downloads\\att_faces\\New folder\\2.pgm"
img = Image.open(image_file)
width, height = img.size

print width
print height
print num_images

M = (X-mean(X.T,axis=1)).T # subtract the mean (along columns)

エラーが発生します:

AttributeError: 'list' object has no attribute 'T'
4

2 に答える 2