message: Extended Keras model testing utils to support ragged and sparse optional params
diff: @@ -485,8 +485,23 @@ class _SubclassModelCustomBuild(keras.Model):
  def get_model_from_layers(layers,
  input_shape=None,
  input_dtype=None,
  - name=None):
  - """Builds a model from a sequence of layers."""
  + name=None,
  + input_ragged=None,
  + input_sparse=None):
  + """Builds a model from a sequence of layers.
  +
  + Args:
  + layers: The layers used to build the network.
  + input_shape: Shape tuple of the input or 'TensorShape' instance.
  + input_dtype: Datatype of the input.
  + name: Name for the model.
  + input_ragged: Boolean, whether the input data is a ragged tensor.
  + input_sparse: Boolean, whether the input data is a sparse tensor.
  +
  + Returns:
  + A Keras model.
  + """
  +
  model_type = get_model_type()
  if model_type == 'subclass':
  return _SubclassModel(layers, name=name)
  @@ -498,8 +513,12 @@ def get_model_from_layers(layers,
  if model_type == 'sequential':
  model = keras.models.Sequential(name=name)
  if input_shape:
  - model.add(keras.layers.InputLayer(input_shape=input_shape,
  - dtype=input_dtype))
  + model.add(
  + keras.layers.InputLayer(
  + input_shape=input_shape,
  + dtype=input_dtype,
  + ragged=input_ragged,
  + sparse=input_sparse))
  for layer in layers:
  model.add(layer)
  return model
  @@ -508,7 +527,11 @@ def get_model_from_layers(layers,
  if not input_shape:
  raise ValueError('Cannot create a functional model from layers with no '
  'input shape.')
  - inputs = keras.Input(shape=input_shape, dtype=input_dtype)
  + inputs = keras.Input(
  + shape=input_shape,
  + dtype=input_dtype,
  + ragged=input_ragged,
  + sparse=input_sparse)
  outputs = inputs
  for layer in layers:
  outputs = layer(outputs)
  