The CK+ dataset is an extension of the CK dataset. It contains 327 labeled facial videos, We extracted the last three frames from each sequence in the CK+ dataset, which contains a total of 981 facial expressions. we use 10-fold Cross validation in the experiment.
there are 135,177,75,207,84,249,54 images in data
we choose 123,159,66,186,75,225,48 images for training
we choose 12,18,9,21,9,24,6 images for testing
the split are in order according to the fold number
number = len(self.data_label) #981
sum_number = [0,135,312,387,594,678,927,981] # the sum of class number
test_number = [12,18,9,21,9,24,6] # the number of each class
test_index = []
train_index = []
for j in range(len(test_number)): #7
for k in range(test_number[j]): #12,18,9,21...
if self.fold != 10: #the last fold start from the last element
test_index.append(sum_number[j]+(self.fold-1)*test_number[j]+k)
else:
test_index.append(sum_number[j+1]-1-k)
for i in range(number):
if i not in test_index:
train_index.append(i)
当fold=1时
当fold=2时
当fold=10时
上面的结果是测试集,下面的结果是验证集
十折交叉验证法就是把每一次划分的每一折的训练集用去训练,把测试集用去测试,循环十次即可。
for i in range(10):
cmd = 'python mainpro_CK+.py --model VGG19 --bs 32 --lr 0.01 --fold %d' %(i+1)