if(require(torch) && torch::torch_is_installed())
{
library(torch)
library(topicmodels.etm)
path <- system.file(package = "topicmodels.etm", "example", "example_etm.ckpt")
model <- torch_load(path)
plot(model, type = "loss")
# \dontshow{
}
# End of main if statement running only if the torch is properly installed
# }
if(require(torch) && torch::torch_is_installed() &&
require(textplot) && require(uwot) && require(ggrepel))
{
library(torch)
library(topicmodels.etm)
library(textplot)
library(uwot)
library(ggrepel)
path <- system.file(package = "topicmodels.etm", "example", "example_etm.ckpt")
model <- torch_load(path)
n_epochs <- NULL
# \dontshow{
n_epochs <- 5
# }
plt <- plot(model, type = "topics", top_n = 7, which = c(1, 2, 14, 16, 18, 19),
metric = "cosine", n_neighbors = 15, n_epochs = n_epochs,
fast_sgd = FALSE, n_threads = 2, verbose = TRUE,
title = "ETM Topics example")
plt
# \dontshow{
}
# End of main if statement running only if the torch is properly installed
# }
Run the code above in your browser using DataLab