torch
torch copied to clipboard
Introductory time series with torch blog example is extremely slow for multi step prediction
the section on multi step prediction is very, very slow on mac os. Any tips or tricks to speed it up?
n_forecast <- 2 * 24 * 7
test_preds <- [vector](https://rdrr.io/r/base/vector.html)(mode = "list", length = [length](https://rdrr.io/r/base/length.html)(test_dl))
i <- 1
coro::loop(for (b in test_dl) {
input <- b$x
output <- net(input$to(device = device))
preds <- [as.numeric](https://rdrr.io/r/base/numeric.html)(output)
for(j in 2:n_forecast) {
input <- torch_cat([list](https://rdrr.io/r/base/list.html)(input[ , 2:[length](https://rdrr.io/r/base/length.html)(input), ], output$view([c](https://rdrr.io/r/base/c.html)(1, 1, 1))), dim = 2)
output <- net(input$to(device = device))
preds <- [c](https://rdrr.io/r/base/c.html)(preds, [as.numeric](https://rdrr.io/r/base/numeric.html)(output))
}
test_preds[[i]] <- preds
i <<- i + 1
})