I am just reading:
Deep Learning and Scientific Computing with R torch:
https://skeydan.github.io/Deep-Learning-and-Scientific-Computing-with-R-torch/
and tried to build the example 14.2.3 with the data from titanic.
The example from the book run smoothly. When I use the titanic data R crashes with fatal error:
train <- train %>% select_if(is.numeric) ## use only numeric columns
train <- train %>% na.omit()### remove NA
## create a torch dataset
ds <- tensor_dataset(
torch_tensor(as.matrix(train[, c(3:7)])),
torch_tensor(as.numeric(train$Survived)
) $to(torch_long()))
d_in <- 5
### dimensionality of hidden layer
d_hidden <- 32
### output dimensionality (number of predicted features)
d_out <- 1
## net module
net <- nn_module(
initialize = function(d_in, d_hidden, d_out) {
self$net <- nn_sequential(
nn_linear(d_in, d_hidden),
nn_relu(),
nn_linear(d_hidden, d_out)
)
},
forward = function(x) {
self$net(x)
}
)
fitted <- net %>%
setup(
loss = nn_mse_loss(),
optimizer = optim_adam) %>% set_hparams(d_in = d_in,
d_hidden = d_hidden,
d_out = d_out) %>%
fit(
ds,
epochs = 200
)
Any ideas what I am doing wrong? I reinstalled torch, all libraries are uptodate.