简体   繁体   中英

How to plot accuracy with a trained model

I have a Tensorflow model already trained in my notebook, and I want to plot accuracy and loss after that.

Here is my code:

myGene = trainGenerator(2,'/content/data/membrane/train','image','label',
                       data_gen_args,save_to_dir = None)
model = unet()
model_checkpoint = ModelCheckpoint('unet_membrane.hdf5', 
                             monitor='loss',verbose=1, save_best_only=True)
model.fit_generator(myGene,steps_per_epoch=2000,
                    epochs=5,callbacks=[model_checkpoint])

Is there a way to plot anything? Because I tried with matplotlib and it doesn't work.

import matplotlib.pyplot as plt

plt.plot(history['accuracy'])
plt.plot(history['loss'])

Try this:

history = model.fit_generator(myGene,
              steps_per_epoch=2000,
              epochs=5,callbacks=[model_checkpoint])

and then, for plotting:

plt.plot(history.history['accuracy'])
plt.plot(history.history['loss'])

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