continue_trainingR Documentation

Continues training of a model generated with dnn for additional epochs.

Description

If the training/validation loss is still decreasing at the end of the training, it is often a sign that the NN has not yet converged. You can use this function to continue training instead of re-training the entire model.

Usage

continue_training(
  model,
  epochs = 32,
  data = NULL,
  device = "cpu",
  verbose = TRUE,
  changed_params = NULL,
  parallel = FALSE
)

## S3 method for class 'citodnn'
continue_training(
  model,
  epochs = 32,
  data = NULL,
  device = "cpu",
  verbose = TRUE,
  changed_params = NULL,
  parallel = FALSE
)

## S3 method for class 'citodnnBootstrap'
continue_training(
  model,
  epochs = 32,
  data = NULL,
  device = "cpu",
  verbose = TRUE,
  changed_params = NULL,
  parallel = FALSE
)

Arguments

model

a model created by dnn

epochs

additional epochs the training should continue for

data

matrix or data.frame if not provided data from original training will be used

device

device on which network should be trained on, either "cpu" or "cuda"

verbose

print training and validation loss of epochs

changed_params

list of arguments to change compared to original training setup, see dnn which parameter can be changed

parallel

train bootstrapped model in parallel

Value

a model of class citodnn or citodnnBootstrap created by dnn

Examples


if(torch::torch_is_installed()){
library(cito)

set.seed(222)
validation_set<- sample(c(1:nrow(datasets::iris)),25)

# Build and train  Network
nn.fit<- dnn(Sepal.Length~., data = datasets::iris[-validation_set,], epochs = 32)

# continue training for another 32 epochs
nn.fit<- continue_training(nn.fit,epochs = 32)

# Use model on validation set
predictions <- predict(nn.fit, iris[validation_set,])
}