绘制损失和模型的准确性

时间:2018-10-22 10:46:37

标签: python plot keras

我具有在keras中构建模型的功能,如下所示:

def build_model(lr = 0.0):
    inp = Input(shape = (max_len,))
    x = Embedding_layer
    y = LSTM_layer(x)
    y = Convolution_layer(y)
    x = GlobalMaxPooling1D(y)

    x = Dense(3, activation = "sigmoid")(x)
    model = Model(inputs = inp, outputs = x)
    model.compile(loss = "binary_crossentropy", optimizer = Adam(), metrics = ["accuracy"])
    history = model.fit(X_train, Y_train, batch_size = 256, epochs = 3, 
                        verbose = 1, callbacks = [ra_val, check_point, early_stop])
    model = load_model(file_path)
    return model

model = build_model(lr = 1e-3)

现在我想在训练阶段后绘制历史记录损失和准确性,但是模型没有历史记录选项。

如何绘制损耗和精度?

1 个答案:

答案 0 :(得分:0)

fit函数将返回一个History对象,其中包含损失值和训练指标。