评估模型时出现 "too many values to unpack (expected 2)" 错误

Getting the "too many values to unpack (expected 2)" error when evaluating a model

每当我尝试评估我的模型时,我总是收到错误“要解压的值太多(预期为 2)”。我不知道是什么导致了这个错误以及如何解决它。谁能帮我解决这个问题?

model = keras.Sequential([
  keras.layers.Conv3D(input_shape=(44,64,64,1), filters=8, kernel_size=3, 
                      strides=2, activation='relu', name='Conv1'),
  keras.layers.Flatten(),
  keras.layers.Dense(2, activation=tf.nn.softmax, name='Softmax')
  ])
model.summary()

batch_size = 16
testing = False
epochs = 3

model.compile(optimizer='adam', 
              loss=keras.losses.SparseCategoricalCrossentropy(),
              metrics=[keras.metrics.SparseCategoricalAccuracy(), 'accuracy'])

model.fit(train_images,
          train_labels,
          validation_data=(test_images, test_labels),
          epochs=epochs)

test_loss, test_acc = model.evaluate(test_images, test_labels) #This is where I am getting the error
print('\nTest accuracy: {}'.format(test_acc))
model.save('my_model.h5')

注意:感谢 Tuqay 指出问题。

解包时始终使用包罗万象的占位符。请参阅下面的示例行为。

test_loss, test_acc, *is_anything_else_being_returned = model.evaluate(test_images, test_labels) #This is where I am getting the error

>>> a = [1,2,3,4,5,6,7]
>>> b,c,*d = a
>>> b
1
>>> c
2
>>> d
[3, 4, 5, 6, 7]
>>>