在迭代过程中,几乎100个数组中的所有数组都被填充,只有两个数组的大小分别为63和27。因此,由于特征数组的大小不同,SVM无法工作
我尝试在底部再次迭代,但没有成功。试图使用条件语句更改维度,但无效
for idx1, f in enumerate(feature):
if idx1 >= 50: break
current_feature.append(f[2])
current_feature.append(f[3])
current_feature.append(f[4])
#fixations.append(feature.feature_list)
current_feature = np.array(current_feature)
pad_amount = 150 - current_feature.size
prev = current_feature.size
np.pad(current_feature, (0, pad_amount), 'constant')
if current_feature.size != 150:
np.pad(current_feature, (0, pad_amount), 'constant')
print(prev)
print(current_feature.size)
feed.append(current_feature)
在100个功能阵列中,仅创建了两个尺寸为67和27的阵列,它们不会被填充
编辑:粘贴代码时键入
np.pad不在原地更改数组,它将返回新数组。试试
current_feature = np.pad(current_feature, (0, pad_amount), 'constant')
(出于同样的原因,您可以删除
np.pad(current_feature, (0, pad_amount), 'constant')
的第一个外观)相关问题 更多 >
编程相关推荐