This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reinforce_test.R
54 lines (48 loc) · 2.76 KB
/
reinforce_test.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
library(aslib)
library (llama)
source('reinforce.R')
# Load dataset -----------------------------------------------------------
dataset_hard <- ExtractHardInstancesGRAPHS2015()
# Tensorboard config -----------------------------------------------------------
LAUNCH_TENSORBOARD <- TRUE
TENSORBOARD_LOGPATH <- paste(getwd(), "test_singlerun")
if (LAUNCH_TENSORBOARD) {
tensorboard(TENSORBOARD_LOGPATH, "stop")
tensorboard(TENSORBOARD_LOGPATH, "start")
}
# Single run -----------------------------------------------------------
model_reinforce <- REINFORCE_AS(dataset_hard, EPOCHS = 25, NUM_BATCHES = 64, DROPOUT_PROB = 0.5, TB_ROOTFOLDER = TENSORBOARD_LOGPATH)
# Tune hyperparameters -----------------------------------------------------------
res_all <- data.frame()
runData <- list()
epochs <- 25
TENSORBOARD_LOGPATH <- paste(getwd(), "test_singlerun")
for (dropout in c(0.3, 0.5)) { #0.7
for(batches in c(16,32)) #64
{
modelName <- paste("BATCH", batches, "DP", dropout, sep = "_")
start_time <- Sys.time()
model_reinforce <- REINFORCE_AS(dataset_hard, EPOCHS = epochs, NUM_BATCHES = batches, DROPOUT_PROB = dropout, TB_ROOTFOLDER = paste("test_multiruns", modelName, sep = "/"), OUTFILE = "test_multiruns.txt")
end_time <- Sys.time()
resrl = data.frame(model = modelName,
mean.misclassification.penalty = mean(misclassificationPenalties(dataset_hard, model_reinforce)),
solved = sum(successes(dataset_hard, model_reinforce)),
mean.performance = mean(parscores(dataset_hard, model_reinforce, factor = 1)),
median.performance = median(parscores(dataset_hard, model_reinforce, factor = 1)))
cat(modelName, ": Mean MCP =", prettyNum(resrl$mean.misclassification.penalty, big.mark = ","), ", Train duration =", end_time - start_time, "minutes\n")
runData[[modelName]] <- model_reinforce
res_all <- rbind(res_all, resrl)
}
}
resvbs = data.frame(model = "virtual best",
mean.misclassification.penalty = mean(misclassificationPenalties(dataset_hard, vbs)),
solved = sum(successes(dataset_hard, vbs)),
mean.performance = mean(parscores(dataset_hard, vbs, factor = 1)),
median.performance = median(parscores(dataset_hard, vbs, factor = 1)))
ressb = data.frame(model = "single best",
mean.misclassification.penalty = mean(misclassificationPenalties(dataset_hard, singleBest)),
solved = sum(successes(dataset_hard, singleBest)),
mean.performance = mean(parscores(dataset_hard, singleBest, factor = 1)),
median.performance = median(parscores(dataset_hard, singleBest, factor = 1)))
res_all <- rbind(resvbs, ressb, res_all)
View(res_all)