|
a |
|
b/man/compile_model.Rd |
|
|
1 |
% Generated by roxygen2: do not edit by hand |
|
|
2 |
% Please edit documentation in R/create_model_utils.R |
|
|
3 |
\name{compile_model} |
|
|
4 |
\alias{compile_model} |
|
|
5 |
\title{Compile model} |
|
|
6 |
\usage{ |
|
|
7 |
compile_model( |
|
|
8 |
model, |
|
|
9 |
solver, |
|
|
10 |
learning_rate, |
|
|
11 |
loss_fn, |
|
|
12 |
label_smoothing = 0, |
|
|
13 |
num_output_layers = 1, |
|
|
14 |
label_noise_matrix = NULL, |
|
|
15 |
bal_acc = FALSE, |
|
|
16 |
f1_metric = FALSE, |
|
|
17 |
auc_metric = FALSE, |
|
|
18 |
layer_dense = NULL |
|
|
19 |
) |
|
|
20 |
} |
|
|
21 |
\arguments{ |
|
|
22 |
\item{model}{A keras model.} |
|
|
23 |
|
|
|
24 |
\item{solver}{Optimization method, options are \verb{"adam", "adagrad", "rmsprop"} or \code{"sgd"}.} |
|
|
25 |
|
|
|
26 |
\item{learning_rate}{Learning rate for optimizer.} |
|
|
27 |
|
|
|
28 |
\item{loss_fn}{Either \code{"categorical_crossentropy"} or \code{"binary_crossentropy"}. If \code{label_noise_matrix} given, will use custom \code{"noisy_loss"}.} |
|
|
29 |
|
|
|
30 |
\item{label_smoothing}{Float in [0, 1]. If 0, no smoothing is applied. If > 0, loss between the predicted |
|
|
31 |
labels and a smoothed version of the true labels, where the smoothing squeezes the labels towards 0.5. |
|
|
32 |
The closer the argument is to 1 the more the labels get smoothed.} |
|
|
33 |
|
|
|
34 |
\item{num_output_layers}{Number of output layers.} |
|
|
35 |
|
|
|
36 |
\item{label_noise_matrix}{Matrix of label noises. Every row stands for one class and columns for percentage of labels in that class. |
|
|
37 |
If first label contains 5 percent wrong labels and second label no noise, then |
|
|
38 |
|
|
|
39 |
\code{label_noise_matrix <- matrix(c(0.95, 0.05, 0, 1), nrow = 2, byrow = TRUE )}} |
|
|
40 |
|
|
|
41 |
\item{bal_acc}{Whether to add balanced accuracy.} |
|
|
42 |
|
|
|
43 |
\item{f1_metric}{Whether to add F1 metric.} |
|
|
44 |
|
|
|
45 |
\item{auc_metric}{Whether to add AUC metric.} |
|
|
46 |
|
|
|
47 |
\item{layer_dense}{Vector specifying number of neurons per dense layer after last LSTM or CNN layer (if no LSTM used).} |
|
|
48 |
} |
|
|
49 |
\value{ |
|
|
50 |
A compiled keras model. |
|
|
51 |
} |
|
|
52 |
\description{ |
|
|
53 |
Compile model |
|
|
54 |
} |
|
|
55 |
\examples{ |
|
|
56 |
\dontshow{if (reticulate::py_module_available("tensorflow")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} |
|
|
57 |
|
|
|
58 |
model <- create_model_lstm_cnn(layer_lstm = 8, compile = FALSE) |
|
|
59 |
model <- compile_model(model = model, |
|
|
60 |
solver = 'adam', |
|
|
61 |
learning_rate = 0.01, |
|
|
62 |
loss_fn = 'categorical_crossentropy') |
|
|
63 |
\dontshow{\}) # examplesIf} |
|
|
64 |
} |