if (FALSE) {
x_data <- matrix(data = runif(500,0,1),nrow = 50,ncol = 5)
y_data <- ifelse(runif(50,0,1) > 0.6, 1L,0L) %>% as.matrix()
x_data2 <- matrix(data = runif(500,0,1),nrow = 50,ncol = 5)
y_data2 <- ifelse(runif(50,0,1) > 0.6, 1L,0L) %>% as.matrix()
build_model = function(hp) {
model = keras_model_sequential()
model %>% layer_dense(units=hp$Int('units',
min_value=32L,
max_value=512L,
step=32L),
input_shape = ncol(x_data),
activation='relu') %>%
layer_dense(units=1L, activation='softmax') %>%
compile(
optimizer= tf$keras$optimizers$Adam(
hp$Choice('learning_rate',
values=c(1e-2, 1e-3, 1e-4))),
loss='binary_crossentropy',
metrics='accuracy')
return(model)
}
tuner = RandomSearch(hypermodel = build_model,
objective = 'val_accuracy',
max_trials = 2,
executions_per_trial = 1)
}
Run the code above in your browser using DataLab