Keras Model composed of a linear stack of layers

keras_model_sequential(layers = NULL, name = NULL, ...)



List of layers to add to the model


Name of model


Arguments passed on to sequential_model_input_layer


an integer vector of dimensions (not including the batch axis), or a tf$TensorShape instance (also not including the batch axis).


Optional input batch size (integer or NULL).


Optional datatype of the input. When not provided, the Keras default float type will be used.


Optional tensor to use as layer input. If set, the layer will use the tf$TypeSpec of this tensor rather than creating a new placeholder tensor.


Boolean, whether the placeholder created is meant to be sparse. Default to FALSE.


Boolean, whether the placeholder created is meant to be ragged. In this case, values of 'NULL' in the 'shape' argument represent ragged dimensions. For more information about RaggedTensors, see this guide. Default to FALSE.


A tf$TypeSpec object to create Input from. This tf$TypeSpec represents the entire batch. When provided, all other args except name must be NULL.


Optional name of the input layer (string).


If any arguments are provided to ..., then the sequential model is initialized with a InputLayer instance. If not, then the first layer passed to a Sequential model should have a defined input shape. What that means is that it should have received an input_shape or batch_input_shape argument, or for some type of layers (recurrent, Dense...) an input_dim argument.

See also


if (FALSE) { library(keras) model <- keras_model_sequential() model %>% layer_dense(units = 32, input_shape = c(784)) %>% layer_activation('relu') %>% layer_dense(units = 10) %>% layer_activation('softmax') model %>% compile( optimizer = 'rmsprop', loss = 'categorical_crossentropy', metrics = c('accuracy') ) # alternative way to provide input shape model <- keras_model_sequential(input_shape = c(784)) %>% layer_dense(units = 32) %>% layer_activation('relu') %>% layer_dense(units = 10) %>% layer_activation('softmax') }