检查模型输入时出错:传递给模型的Numpy数组列表不是模型所需的大小

2024-09-30 02:19:36 发布

您现在位置:Python中文网/ 问答频道 /正文

当我试图使用validation_数据来输入我自己的验证集时,遇到了一个错误。

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-53-e2816bdbad19> in <module>
      2                      np.array(X_char_tr).reshape((len(X_char_tr), max_len, max_len_char))],
      3                     np.array(y_tr).reshape(len(y_tr), max_len, 1),
----> 4                     batch_size=32, epochs=10, validation_data=[X_word_te, y_te], verbose=1)

ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead got the following list of 1 arrays: [array([[ 7993, 30540, 29051, ...,     0,     0,     0],
       [ 9571, 24132, 14066, ...,     0,     0,     0],
       [19338, 15304,  7322, ...,     0,     0,     0],
       ...,
       [ 5062, 2713...

这是我的jupyter笔记本的导出,它是发布到这个blog的示例的副本

ner数据集从这里https://www.kaggle.com/abhinavwalia95/entity-annotated-corpus

^{pr2}$

编辑:添加模型摘要

model.summary()

Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_2 (InputLayer)            (None, 75, 10)       0                                            
__________________________________________________________________________________________________
input_1 (InputLayer)            (None, 75)           0                                            
__________________________________________________________________________________________________
time_distributed_1 (TimeDistrib (None, 75, 10, 10)   1000        input_2[0][0]                    
__________________________________________________________________________________________________
embedding_1 (Embedding)         (None, 75, 20)       703600      input_1[0][0]                    
__________________________________________________________________________________________________
time_distributed_2 (TimeDistrib (None, 75, 20)       2480        time_distributed_1[0][0]         
__________________________________________________________________________________________________
concatenate_1 (Concatenate)     (None, 75, 40)       0           embedding_1[0][0]                
                                                                 time_distributed_2[0][0]         
__________________________________________________________________________________________________
spatial_dropout1d_1 (SpatialDro (None, 75, 40)       0           concatenate_1[0][0]              
__________________________________________________________________________________________________
bidirectional_1 (Bidirectional) (None, 75, 100)      36400       spatial_dropout1d_1[0][0]        
__________________________________________________________________________________________________
time_distributed_3 (TimeDistrib (None, 75, 18)       1818        bidirectional_1[0][0]            
==================================================================================================
Total params: 745,298
Trainable params: 745,298
Non-trainable params: 0

Tags: thetononeinputmodellentimeparams

热门问题