Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ValueError:形状(无,8)和(无,10)不兼容_Python_Keras_Sequential - Fatal编程技术网

Python ValueError:形状(无,8)和(无,10)不兼容

Python ValueError:形状(无,8)和(无,10)不兼容,python,keras,sequential,Python,Keras,Sequential,我正在为一个音频分类项目建立一个ANN模型。在计算模型的精度时,我得到了一个误差。X_列、X_测试、y_列和y_测试的形状&错误消息可在代码中看到: X_train.shape (162, 1122) X_test.shape (31, 1122) y_train.shape (162, 10) y_test.shape (31, 8) score = model.evaluate(X_

我正在为一个音频分类项目建立一个ANN模型。在计算模型的精度时,我得到了一个误差。X_列、X_测试、y_列和y_测试的形状&错误消息可在代码中看到:

     X_train.shape
     (162, 1122)

     X_test.shape
     (31, 1122)

     y_train.shape
     (162, 10)

     y_test.shape
     (31, 8)      

     score = model.evaluate(X_test, y_test, verbose=0)
     accuracy = 100*score[1]
     
     ValueError                     Traceback (most recent call last)
    <ipython-input-56-8528a33f6df3> in <module>
----> 1 score = model.evaluate(X_test, y_test, verbose=0)
      2 accuracy = 100*score[1]
     ValueError: Shapes (None, 8) and (None, 10) are incompatible
X_列车形状
(162, 1122)
X_检验形状
(31, 1122)
y_train.shape
(162, 10)
y_检验形状
(31, 8)      
分数=模型。评估(X_检验,y_检验,详细度=0)
准确度=100*分[1]
ValueError回溯(最近一次调用上次)
在里面
---->1分=模型评估(X_检验、y_检验、详细度=0)
2准确度=100*分[1]
ValueError:形状(无,8)和(无,10)不兼容

如何解决此问题?

为什么
y\u train
y\u test
的输出大小不同?您可以通过提供正确的大小来解决此问题。我已经为y_train和y_test提供了正确的大小,但仍然会得到相同的值错误。它们不能是正确的大小,因为其中一个样本的大小为10,另一个样本的大小为8。你需要使用不同的数据来匹配你的模型。我的意思是我通过匹配y_序列和y_测试的样本大小来纠正,这两个样本大小相等,但我得到了相同的错误。我应该在我之前的评论中说得更具体些,我的坏消息。