Keras模型不允许我在单个数据点上进行主动学习培训

2024-09-28 22:19:35 发布

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

我有一个Keras模型,下面的摘要保存到一个文件中

    Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_1 (Conv2D)            (None, 70, 8, 64)         640       
_________________________________________________________________
dense_1 (Dense)              (None, 70, 8, 720)        46800     
_________________________________________________________________
dense_2 (Dense)              (None, 70, 8, 720)        519120    
_________________________________________________________________
dense_3 (Dense)              (None, 70, 8, 100)        72100     
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 68, 6, 32)         28832     
_________________________________________________________________
flatten_1 (Flatten)          (None, 13056)             0         
_________________________________________________________________
dense_4 (Dense)              (None, 2)                 26114     
=================================================================
Total params: 693,606
Trainable params: 693,606
Non-trainable params: 0
_________________________________________________________________
None

我的训练和测试数据形状分别为(120,72,10,1)和(20,72,10,1)。 当我尝试并重新训练时,当我尝试在单个数据点(1,72,10,1)上训练时,模型不会接受任何小于(4,72,10,1)的值。 以下是我收到的错误

Traceback (most recent call last):
  File "./classifier.py", line 62, in <module>
    classifier.fit(test_point, y_test[i])
  File "/home/jazz/.local/lib/python3.5/site-packages/keras/engine/training.py", line 952, in fit
    batch_size=batch_size)
  File "/home/jazz/.local/lib/python3.5/site-packages/keras/engine/training.py", line 789, in _standardize_user_data
    exception_prefix='target')
  File "/home/jazz/.local/lib/python3.5/site-packages/keras/engine/training_utils.py", line 138, in standardize_input_data
    str(data_shape))
ValueError: Error when checking target: expected dense_4 to have shape (2,) but got array with shape (1,)

我不知道如何推进这项工作,任何帮助都将不胜感激


Tags: inpynonehomelibpackageslocalline