title: Variable length input with Keras/Tensorflow Serving
body: <p>I'm trying to build a Keras model that will be exported to TF serving for text classification. The model supports variable length inputs (or at least, I can feed in inputs of any length when evaluating), but I can't figure out how to describe this when generating the classification signature for TF serving</p>
  
  <p>Currently, I'm doing:</p>
  
  <pre><code>  # Create the input tensors
    serialized_tf_example = tf.placeholder(tf.string, name='tf_example')
    feature_configs = {'input': tf.VarLenFeature(tf.int64)}
    tf_example = tf.parse_example(serialized_tf_example, feature_configs)
    output_tensor = model(tf_example['input'])
  
    # Create the prediction output tensors
    values, indices = tf.nn.top_k(output_tensor, len(binarizer.classes_))
    table = tf.contrib.lookup.index_to_string_table_from_tensor(tf.constant(binarizer.classes_))
    prediction_classes = table.lookup(tf.to_int64(indices))
  
    # Generate a classification signature
    signature = tf.saved_model.signature_def_utils.classification_signature_def(
      serialized_tf_example,
      prediction_classes,
      values
    )
  </code></pre>
  
  <p>However, this fails because <code>VarLenFeature</code> parses to a <code>SparseTensor</code>, which the embedding layer does not support. However, if I change <code>VarLenFeature</code> to a <code>FixedLenFeature</code>, then I have to provide fixed inputs to the tensorflow model, which is suboptimal for this case.</p>
  
  <p>The actual error I get when trying this is:</p>
  
  <pre><code>TypeError: Failed to convert object of type &lt;class 'tensorflow.python.framework.sparse_tensor.SparseTensor'&gt; to Tensor. Contents: SparseTensor(indices=Tensor("ParseExample/ParseExample:0", shape=(?, 2), dtype=int64), values=Tensor("ParseExample/ParseExample:1", shape=(?,), dtype=int64), dense_shape=Tensor("ParseExample/ParseExample:2", shape=(2,), dtype=int64)). Consider casting elements to a supported type.
  </code></pre>
  
  <p>I'm not sure what else I can do to inform TF serving that variable length inputs are supported in the graph - or if this is even possible when using keras.</p>