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)
topic.centers <- as.matrix(model, type = "embedding", which = "topics")
word.embeddings <- as.matrix(model, type = "embedding", which = "words")
topic.terminology <- as.matrix(model, type = "beta")
# \dontshow{
}
# End of main if statement running only if the torch is properly installed
# }
Run the code above in your browser using DataLab