我正在尝试运行微表情识别代码,这是链接:https://github.com/bogireddytejareddy/micro-expression-recognition
我遇到一个特定的错误,这是引发错误的代码:
training_list = [a.reshape(-1, 2) for a in training_list]
training_list = numpy.asarray(training_list)
trainingsamples = len(training_list)
traininglabels = numpy.zeros((trainingsamples, ), dtype = int)
traininglabels[0:66] = 0
traininglabels[66:113] = 1
traininglabels[113:156] = 2
traininglabels = np_utils.to_categorical(traininglabels, 3)
training_data = [training_list, traininglabels]
(trainingframes, traininglabels) = (training_data[0], training_data[1])
training_set = numpy.zeros((trainingsamples, 1, image_rows, image_columns, image_depth))
for h in range(trainingsamples):
training_set[h][0][:][:][:] = trainingframes[h, :, :, :]
training_set = training_set.astype('float32')
training_set -= numpy.mean(training_set)
training_set /= numpy.max(training_set)
错误窗口是:
Using TensorFlow backend.
Traceback (most recent call last):
File "/Users/Rajat_Sharma/PycharmProjects/untitled1/micro-expression-recognition-master/SMIC/MicroExpSTCNN.py", line 93, in <module>
training_set[h][0][:][:][:] = trainingframes[h, :, :, :]
IndexError: too many indices for array
Process finished with exit code 1
请帮助。原谅我犯了明显的错误,但我是初学者。
编辑:training_set的形状打印为(7,1,64,64,18),trainingframes的形状打印为(7,)现在,请告诉我代码中要进行哪些更改?许多thanx。
答案 0 :(得分:0)
错误非常明显,括号中的索引数比数组的维数多。
检查训练集和训练框架的形状->打印(training_set.shape())