knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 5 )
{kindling} bridges the gap between {torch} and {tidymodels}, providing a streamlined interface for building, training, and tuning deep learning models. This vignette will guide you through the basic usage.
You can install {kindling} on CRAN:
install.packages('kindling')
Or install the development version from GitHub:
# install.packages("pak") pak::pak("joshuamarie/kindling") ## devtools::install_github("joshuamarie/kindling")
library(kindling)
Before starting, you need to install LibTorch, the backend of PyTorch which also the backend of {torch} R package:
torch::install_torch()
{kindling} offers flexibility through four levels of abstraction:
torch::nn_module codeparsnip, recipes, and workflowstune and dialsGenerate PyTorch-style module code:
ffnn_generator( nn_name = "MyNetwork", hd_neurons = c(64, 32), no_x = 10, no_y = 1, activations = 'relu' )
Train a model with one function call:
model = ffnn( Species ~ ., data = iris, hidden_neurons = c(10, 15, 7), activations = act_funs(relu, elu), # c("relu", "elu") loss = "cross_entropy", epochs = 100 ) predictions = predict(model, newdata = iris)
Work with neural networks like any other parsnip model:
box::use( parsnip[fit, augment], yardstick[metrics] ) nn_spec = mlp_kindling( mode = "classification", hidden_neurons = c(10, 7), activations = act_funs(relu, softshrink = args(lambd = 0.5)), epochs = 100 ) nn_fit = fit(nn_spec, Species ~ ., data = iris) augment(nn_fit, new_data = iris) |> metrics(truth = Species, estimate = .pred_class)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.