View source: R/run_classifier.R
input_fn_builder | R Documentation |
input_fn
closure to be passed to TPUEstimatorCreates an input_fn
closure to be passed to TPUEstimator. The output
of this closure is the (modified) output of
tensorflow::tf$data$Dataset$from_tensor_slices
(an object of class
"tensorflow.python.data.ops.dataset_ops.BatchDataset").
input_fn_builder(features, seq_length, is_training, drop_remainder)
features |
A list of features (objects of class |
seq_length |
Integer; the maximum length (number of tokens) of each example. (Examples should already be padded to this length by this point.) |
is_training |
Logical; whether these are training examples. |
drop_remainder |
Logical; whether to drop the extra if the number of elements in the dataset is not an exact multiple of the batch size, |
An input_fn
closure to be passed to TPUEstimator.
## Not run: tokenizer <- FullTokenizer("vocab.txt") seq_len <- 15L input_ex1 <- InputExample( guid = 1L, text_a = "Some text to classify.", text_b = "More wordy words.", label = "good" ) input_ex2 <- InputExample( guid = 2L, text_a = "This is another example.", text_b = "So many words.", label = "bad" ) feat <- convert_examples_to_features( examples = list(input_ex1, input_ex2), label_list = c("good", "bad"), max_seq_length = seq_len, tokenizer = tokenizer ) input_fn <- input_fn_builder( features = feat, seq_length = seq_len, is_training = TRUE, drop_remainder = FALSE ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.