使用 R Keras 包时,如何获取 R 中每个调整 运行 中使用的标志值?
How to get the flag values used in each tuning run in R when using the R Keras package?
我正在尝试使用 keras 包在 R 中使用标志和 tuning_run 调整完全连接的深度学习模型的超参数。我在哪里可以找到每个 运行 中使用的实际标志值?
我尝试寻找在生成的结果数据框和 运行s/ 文件夹中使用的超参数值。虽然所有关于 运行 的精度值、损失函数和其他元细节都在那里,但不包括生成这些结果的超参数(我按照这里给出的这个例子:https://tensorflow.rstudio.com/tools/tfruns/articles/tuning.html)。我正在调用我的 tuning_run,如下所示
runs <- tuning_run("test.R", flags = list(dropout1=c(0.5,0.4,0.3),dropout2=c(0.3,0.2),dense_units=c(128,256)),sample=0.3)
并且我的模型使用
这样的标志
model <- keras_model_sequential()
model %>%
layer_dense(units = 256, activation = 'relu', input_shape = c(784)) %>%
layer_dropout(rate = FLAGS$dropout_1) %>%
layer_dense(units = FLAGS$dense_units, activation = 'relu') %>%
layer_dropout(rate = FLAGS$dropout_2) %>%
layer_dense(units = 10, activation = 'softmax')
当我 运行 它时,稍后会查找为其生成特定验证准确性的标志的值(运行s 数据框)这就是我观察到的
Data frame: 2 x 25
run_dir eval_loss eval_acc metric_loss metric_acc
1 runs/2019-03-29T00-14-10Z 0.1315 0.9794 0.0075 0.9977
2 runs/2019-03-29T00-10-37Z 0.1326 0.9816 0.0096 0.9973
metric_val_loss metric_val_acc
1 0.1475 0.9794
2 0.1443 0.9794
# ... with 18 more columns:
# samples, validation_samples, batch_size, epochs, epochs_completed,
# metrics, model, loss_function, optimizer, learning_rate, script, start,
# end, completed, output, source_code, context, type
我想知道在哪里可以找到每次迭代中使用的标志值。还是我做错了什么?任何帮助,将不胜感激。谢谢!
我发现问题出在哪里了。这些标志也需要在目标脚本中定义,以便 keras 报告它。这就是为什么它没有在结果帧中显示标志的原因。
一旦我将这些行添加到 test.R 它工作正常
FLAGS <- flags(
flag_numeric('dropout_1', 0.04, 'First dropout'),
flag_numeric('dropout_2', 0.3, 'Second dropout'),
flag_integer('dense_units', 128, 'Units in dense layer')
)
同样的问题和解决方案在这里讨论:https://github.com/rstudio/tfruns/issues/24
我正在尝试使用 keras 包在 R 中使用标志和 tuning_run 调整完全连接的深度学习模型的超参数。我在哪里可以找到每个 运行 中使用的实际标志值?
我尝试寻找在生成的结果数据框和 运行s/ 文件夹中使用的超参数值。虽然所有关于 运行 的精度值、损失函数和其他元细节都在那里,但不包括生成这些结果的超参数(我按照这里给出的这个例子:https://tensorflow.rstudio.com/tools/tfruns/articles/tuning.html)。我正在调用我的 tuning_run,如下所示
runs <- tuning_run("test.R", flags = list(dropout1=c(0.5,0.4,0.3),dropout2=c(0.3,0.2),dense_units=c(128,256)),sample=0.3)
并且我的模型使用
这样的标志model <- keras_model_sequential()
model %>%
layer_dense(units = 256, activation = 'relu', input_shape = c(784)) %>%
layer_dropout(rate = FLAGS$dropout_1) %>%
layer_dense(units = FLAGS$dense_units, activation = 'relu') %>%
layer_dropout(rate = FLAGS$dropout_2) %>%
layer_dense(units = 10, activation = 'softmax')
当我 运行 它时,稍后会查找为其生成特定验证准确性的标志的值(运行s 数据框)这就是我观察到的
Data frame: 2 x 25
run_dir eval_loss eval_acc metric_loss metric_acc
1 runs/2019-03-29T00-14-10Z 0.1315 0.9794 0.0075 0.9977
2 runs/2019-03-29T00-10-37Z 0.1326 0.9816 0.0096 0.9973
metric_val_loss metric_val_acc
1 0.1475 0.9794
2 0.1443 0.9794
# ... with 18 more columns:
# samples, validation_samples, batch_size, epochs, epochs_completed,
# metrics, model, loss_function, optimizer, learning_rate, script, start,
# end, completed, output, source_code, context, type
我想知道在哪里可以找到每次迭代中使用的标志值。还是我做错了什么?任何帮助,将不胜感激。谢谢!
我发现问题出在哪里了。这些标志也需要在目标脚本中定义,以便 keras 报告它。这就是为什么它没有在结果帧中显示标志的原因。
一旦我将这些行添加到 test.R 它工作正常
FLAGS <- flags(
flag_numeric('dropout_1', 0.04, 'First dropout'),
flag_numeric('dropout_2', 0.3, 'Second dropout'),
flag_integer('dense_units', 128, 'Units in dense layer')
)
同样的问题和解决方案在这里讨论:https://github.com/rstudio/tfruns/issues/24