解决ValueError: Found input variables with inconsistent numbers of samples

问题描述:主要是运行中提示 ValueError: Found input variables with inconsistent numbers of samples

百度可知 :参考 成功解决ValueError: Found input variables with inconsistent numbers of samples: [86, 891]_一个处女座的程序猿-CSDN博客成功解决ValueError: Found input variables with inconsistent numbers of samples: [86, 891]目录解决问题解决思路解决方法解决问题ValueError: Found input variables with inconsistent numbers of samples...https://blog.csdn.net/qq_41185868/article/details/86655508

其中提到可能是因为输入参数变量与样本数不一致,于是我也进行了输出参数变量的形状查看,发现的确不一致,我的 train_x 是一个三维数据,而 train_y 数据标签是两维的,当然前两维数据是一致的。

我的原问题代码:

train_x, train_y = data_loader.load_data()

train_x = np.array(train_x)
train_y = np.array(train_y)
print(train_x.shape)
print(train_y.shape)

添加代码:

train_x = np.reshape(train_x,[train_x.shape[0]*train_x.shape[1],-1])
train_y = train_y.flatten()
print("\n")
print(train_x.shape)
print(train_y.shape)

此时即可大功告成,其中错漏之处,万望包涵。

你可能感兴趣的:(深度学习,人工智能)