Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

column_embedding

Construct a Dense Column


Description

Use this when your inputs are sparse, but you want to convert them to a dense representation (e.g., to feed to a DNN). Inputs must be a categorical column created by any of the column_categorical_*() functions.

Usage

column_embedding(categorical_column, dimension, combiner = "mean",
  initializer = NULL, ckpt_to_load_from = NULL,
  tensor_name_in_ckpt = NULL, max_norm = NULL, trainable = TRUE)

Arguments

categorical_column

A categorical column created by a column_categorical_*() function. This column produces the sparse IDs that are inputs to the embedding lookup.

dimension

A positive integer, specifying dimension of the embedding.

combiner

A string specifying how to reduce if there are multiple entries in a single row. Currently "mean", "sqrtn" and "sum" are supported, with "mean" the default. "sqrtn"' often achieves good accuracy, in particular with bag-of-words columns. Each of this can be thought as example level normalizations on the column.

initializer

A variable initializer function to be used in embedding variable initialization. If not specified, defaults to tf$truncated_normal_initializer with mean 0.0 and standard deviation 1 / sqrt(dimension).

ckpt_to_load_from

String representing checkpoint name/pattern from which to restore column weights. Required if tensor_name_in_ckpt is not NULL.

tensor_name_in_ckpt

Name of the Tensor in ckpt_to_load_from from which to restore the column weights. Required if ckpt_to_load_from is not NULL.

max_norm

If not NULL, embedding values are l2-normalized to this value.

trainable

Whether or not the embedding is trainable. Default is TRUE.

Value

A dense column that converts from sparse input.

Raises

  • ValueError: if dimension not > 0.

  • ValueError: if exactly one of ckpt_to_load_from and tensor_name_in_ckpt is specified.

  • ValueError: if initializer is specified and is not callable.

See Also


tfestimators

Interface to 'TensorFlow' Estimators

v1.9.1
Apache License 2.0
Authors
JJ Allaire [aut], Yuan Tang [aut] (<https://orcid.org/0000-0001-5243-233X>), Kevin Ushey [aut], Kevin Kuo [aut, cre] (<https://orcid.org/0000-0001-7803-7901>), Daniel Falbel [ctb, cph], RStudio [cph, fnd], Google Inc. [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.