| nn_multi_embedding | R Documentation |
It is especially useful, for dealing with multiple categorical features.
nn_multi_embedding( num_embeddings, embedding_dim, padding_idx = NULL, max_norm = NULL, norm_type = 2, scale_grad_by_freq = FALSE, sparse = FALSE, .weight = NULL )
num_embeddings |
( |
embedding_dim |
( |
padding_idx |
( |
max_norm |
( |
norm_type |
( |
scale_grad_by_freq |
( |
sparse |
( |
.weight |
( |
library(recipes)
data("gss_cat", package = "forcats")
gss_cat_transformed <-
recipe(gss_cat) %>%
step_integer(everything()) %>%
prep() %>%
juice()
gss_cat_transformed <- na.omit(gss_cat_transformed)
gss_cat_transformed <-
gss_cat_transformed %>%
mutate(across(where(is.numeric), as.integer))
glimpse(gss_cat_transformed)
gss_cat_tensor <- as_tensor(gss_cat_transformed)
.dict_size <- dict_size(gss_cat_transformed)
.dict_size
.embedding_size <- embedding_size_google(.dict_size)
embedding_module <-
nn_multi_embedding(.dict_size, .embedding_size)
# Expected output size
sum(.embedding_size)
embedding_module(gss_cat_tensor)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.