Have you already checked:

  

      github.com/tensorflow/tensorflow
  

  
    
  
	  
  

  
    
      Ragged Tensors in Keras Model Output 50
    

    
      
        opened 
        
          
        
        Aug 13, 2020
      
      


      
        
          
          ablanch5
        
      
    

    
        
          stat:awaiting tensorflower
        
        
          type:feature
        
        
          comp:keras
        
    
  


  
    **System information**
- TensorFlow version (you are using): 2.3.0
- Are you w…illing to contribute it (Yes/No): No



**Describe the feature and the current behavior/state.**
I don't think ragged tensors are supported as the outputs to a model. For example the following code does not work

import tensorflow as tf

y_pred = tf.ragged.constant([[0], [0, 0]])
y_true = tf.ragged.constant([[1], [1,1]])

model = tf.keras.Sequential([
    tf.keras.layers.Input(shape=(None,), ragged=True)
])

model.compile(loss='MSE', optimizer='adam')
model.evaluate(x=y_pred, y=y_true)

Returns error:
 TypeError: Failed to convert object of type <class 'tensorflow.python.ops.ragged.ragged_tensor.RaggedTensor'> to Tensor. Contents: tf.RaggedTensor(values=Tensor("sequential_1/Cast_1:0", shape=(None,), dtype=float32), row_splits=Tensor("RaggedFromVariant/RaggedTensorFromVariant:0", shape=(None,), dtype=int64)). Consider casting elements to a supported type.

**Will this change the current api? How?**
yes. implement support for ragged tensors in keras model output

**Who will benefit with this feature?**
People who want to use ragged tensors in output, for example sequence to sequence models with variable lengths.

**Any Other info.**
No.