Learn R Programming

keras (version 2.0.9)

pad_sequences: Pads each sequence to the same length (length of the longest sequence).

Description

Pads each sequence to the same length (length of the longest sequence).

Usage

pad_sequences(sequences, maxlen = NULL, dtype = "int32", padding = "pre",
  truncating = "pre", value = 0)

Arguments

sequences

List of lists where each element is a sequence

maxlen

int, maximum length

dtype

type to cast the resulting sequence.

padding

'pre' or 'post', pad either before or after each sequence.

truncating

'pre' or 'post', remove values from sequences larger than maxlen either in the beginning or in the end of the sequence

value

float, value to pad the sequences to the desired value.

Value

Array with dimensions (number_of_sequences, maxlen)

Details

If maxlen is provided, any sequence longer than maxlen is truncated to maxlen. Truncation happens off either the beginning (default) or the end of the sequence. Supports post-padding and pre-padding (default).

See Also

Other text preprocessing: make_sampling_table, skipgrams, text_hashing_trick, text_one_hot, text_to_word_sequence