View source: R/preprocessing.R
pad_sequences | R Documentation |
Transform a list of num_samples sequences (lists of scalars) into a 2D Numpy array of shape (num_samples, num_timesteps). num_timesteps is either the maxlen argument if provided, or the length of the longest sequence otherwise. Sequences that are shorter than num_timesteps are padded with value at the end. Sequences longer than num_timesteps are truncated so that it fits the desired length. Position where padding or truncation happens is determined by padding or truncating, respectively.
pad_sequences(sequences, maxlen = NULL, dtype = "int32", padding = "pre", truncating = "pre", value = 0)
sequences |
vector of lists of int or float. |
maxlen |
None or int. Maximum sequence length, longer sequences are truncated and shorter sequences are padded with zeros at the end. |
dtype |
datatype of the Numpy array returned. |
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. |
Taylor B. Arnold, taylor.arnold@acm.org
Chollet, Francois. 2015. Keras: Deep Learning library for Theano and TensorFlow.
Other preprocessing: Tokenizer
,
expand_dims
, img_to_array
,
load_img
, one_hot
,
text_to_word_sequence
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.