我想计算测试数据中每个图像的损失和准确性。这样我就可以计算出平均损失和准确性及其标准偏差。
我正在使用U-Net模型进行图像分割。我将数据分为训练数据和测试数据,它们都有图像和标签。
data_gen_args = dict(rotation_range=0.2, width_shift_range=0.05, height_shift_range=0.05, shear_range=0.05,
zoom_range=0.05, horizontal_flip=True, fill_mode='nearest')
trainGene = trainGenerator(1,'./data/melanoma/train','image','label',data_gen_args,save_to_dir = None)
model = unet()
tensorboard = TensorBoard(log_dir='./logs', histogram_freq=0,write_graph=True, write_images=False)
model_checkpoint = ModelCheckpoint('./models/unet_model.hdf5', monitor='loss',verbose=1, save_best_only=True)
history = model.fit_generator(trainGene,steps_per_epoch=2,epochs=1,callbacks=[model_checkpoint,tensorboard])
print(history.history)
print("number of epoch",history.epoch)
data_gen_args = dict(rotation_range=0.2, width_shift_range=0.05, height_shift_range=0.05, shear_range=0.05,
zoom_range=0.05, horizontal_flip=True, fill_mode='nearest')
evaluateGene = validGenerator(1,'./data/melanoma/test','image','label',data_gen_args,save_to_dir = None)
score = model.evaluate_generator(evaluateGene,20, verbose=1)
print(model.metrics_names)
print(score[0], score[1],score[2])
testGene = testGenerator("data/melanoma/test/image")
results = model.predict_generator(testGene,20,verbose=1)
saveResult("data/melanoma/test/predict",results)
我希望输出可以是每个测试图像的损失和准确性的数组。 谢谢!