如何修复keras.callbacks.EarlyStopping中不受支持的操作数错误

时间:2018-12-27 10:55:51

标签: python-3.x keras neural-network

如果没有任何改进,我尝试使用回调来停止迭代,但是会遇到此错误:

    TypeError: unsupported operand type(s) for +: 'EarlyStopping' and 'list'

共享产生上述错误的代码。

    sgd = krs.optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)

    model.compile(
     optimizer = "sgd",
     loss = "binary_crossentropy",
     metrics = ["accuracy"]
    )

    results = model.fit(
        train_X, train_Y
        ,epochs = 10
        ,batch_size = 100
        ,class_weight = {1:10.11, 0:1}
        ,shuffle = 1
        ,validation_data = (test_X, test_Y)
        ,verbose = 1
        ,callbacks = krs.callbacks.EarlyStopping(monitor='val_loss', min_delta = 0, patience=2, verbose=0, mode="auto")
    )

0 个答案:

没有答案