模型评估精度不符合预期

时间:2019-07-03 20:28:15

标签: r machine-learning keras

我正在使用keras软件包R运行机器学习模型。我遇到了多分类问题,在这里我要对50位作家的笔迹进行分类。该模型有50个纪元。当我运行模型时,在最后一个时期,训练数据的最高分类精度为0.8179,而验证集的精度为0.6927。但是,在评估模型(evaluaute_generator)时,训练数据的准确性比预期的要高得多-0.96875。我是机器学习的新手。这看起来正确吗?

 train_history_subset_1 <-
    model %>%
    fit_generator(
      data_gen,
      steps_per_epoch = steps_per_epoch_train,
      validation_data = val_gen,
      validation_steps = steps_per_epoch_val,
      epochs = 50)



#######################################
Resulting epochs - last 5
#######################################
Epoch 45/50
401/401 [==============================] - 33s 81ms/step - loss: 0.5937 - categorical_accuracy: 0.8017 - val_loss: 1.0380 - val_categorical_accuracy: 0.6894
Epoch 46/50
401/401 [==============================] - 32s 80ms/step - loss: 0.6063 - categorical_accuracy: 0.8024 - val_loss: 1.0911 - val_categorical_accuracy: 0.6787
Epoch 47/50
401/401 [==============================] - 36s 90ms/step - loss: 0.6039 - categorical_accuracy: 0.8044 - val_loss: 1.1850 - val_categorical_accuracy: 0.6511
Epoch 48/50
401/401 [==============================] - 35s 88ms/step - loss: 0.6199 - categorical_accuracy: 0.8007 - val_loss: 1.0575 - val_categorical_accuracy: 0.6745
Epoch 49/50
401/401 [==============================] - 36s 89ms/step - loss: 0.6053 - categorical_accuracy: 0.8073 - val_loss: 1.1501 - val_categorical_accuracy: 0.6651
Epoch 50/50
401/401 [==============================] - 35s 86ms/step - loss: 0.5580 - categorical_accuracy: 0.8179 - val_loss: 1.0366 - val_categorical_accuracy: 0.6927

##########################
Evaluation and results
##########################

 train_evaluate_subset_1 <- 
   model %>%
    evaluate_generator(
      data_gen, 
      steps = batch_size
    )

  val_evaluate_subset_1 <- 
    model %>%
    evaluate_generator(
     val_gen, 
      steps = batch_size
    )

train_evaluate_subset_1

val_evaluate_subset_1

###### Results ###########
> train_evaluate_subset_1
$loss
[1] 0.1584623

$categorical_accuracy
[1] 0.96875

> 
> val_evaluate_subset_1
$loss
[1] 1.020088

$categorical_accuracy
[1] 0.6914062

我原本希望我的训练数据的分类准确度接近80%,但也许我的理解是错误的。

0 个答案:

没有答案