forked from bkrai/DeepLearningR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHyperparameterTuning
More file actions
35 lines (28 loc) · 771 Bytes
/
HyperparameterTuning
File metadata and controls
35 lines (28 loc) · 771 Bytes
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
# Libraries
library(keras)
library(tensorflow)
library(tfruns)
# Data
data <- read.csv('CTG.csv', header = T)
# Matrix
data <- as.matrix(data)
dimnames(data) <- NULL
# Normalize
data[, 1:21] <- normalize(data[,1:21])
data[,22] <- as.numeric(data[,22]) -1
# Partition
set.seed(1234)
ind <- sample(2, nrow(data), replace = T, prob = c(0.7, 0.3))
training <- data[ind == 1, 1:21]
test <- data[ind == 2, 1:21]
trainingtarget <- data[ind == 1, 22]
testtarget <- data[ind == 2, 22]
# One-hot encoding
trainLabels <- to_categorical(trainingtarget)
testLabels <- to_categorical(testtarget)
# Hyperparameter tuning
runs <- tuning_run("experiment.R",
flags = list(dense_units = c(32, 64)))
# Best hyperparameter values
head(runs)
results <- runs[,c(5,6)]