简体   繁体   中英

plot loss and accuracy of a model in keras

i have a function to build a model in keras such as below:

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)

and now i want to plot history loss and accuracy after training phase, but model doesn't have history option.

how can i plot loss and accuracy ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM