Skip to contents

This function performs a one-hot encoding of the label, transform a label with N letters in a matrix of dimensions Nxlength(vocab). All the labels must have the same length.

Usage

captcha_transform_label(all_letters, vocab)

Arguments

all_letters

list of tokens for all files

vocab

unique tokens

Value

torch tensor with dimensions length(all_letters)xlength(vocab)

containing only zeros and ones. All rows sum exactly one.

Examples


if (torch::torch_is_installed()) {
  vocab <- letters
  resp <- captcha_transform_label(c("a","b","c","d","e"), vocab)
  class(resp)
  dim(resp)
}