How to pass zipped Tensors and RaggedTensors to .fit()?
Hi **@mihalt** ,
Sorry for the delay, Unpack the zipped data in your training loop:
This is the simplest approach and works well for small datasets or when you need more control over the individual Tensors and RaggedTensors.
Inside your training loop, unpack the zipped data into separate variables for your features and labels.

Thank you! > Hi **@mihalt** , Sorry for the delay, Unpack the zipped data in your training loop: This is the simplest approach and works well for small datasets or when you need more control over the individual Tensors and RaggedTensors. Inside your training loop, unpack the zipped data into separate variables for your features and labels.
> 
> Thank you!

oh, do you offer to do custom training loop? Really not happy with this. Do you think is it a bug? Do you plan to fix it in near releases of tensorflow? I would better prefer to wait when you do it.  Hi @mihalt ,

The `fit` method indeed takes input as `tf.data.Dataset` object which can accept Ragged Tensors as input also.

From the error it seems you are passing `rank1` scalar values as input.Ragged tensors should have atleast rank2.



> oh, do you offer to do custom training loop? Really not happy with this. Do you think is it a bug? Do you plan to fix it in near releases of tensorflow? I would better prefer to wait when you do it.

For passing Ragged input there is no need of custom loop. You can pass it directly to model.fit . But the ragged input should be qualified as `>= rank2 ` What my colleague is trying to say is that by using the `Dataset` class he gets a set of **input data** and **target**. In this case, the `dataset `has shapes `[batch_size, ragged_rank1, ragged_rank2, embedding_dim]`. According to it, the **targets data** have shapes `[batch_size, ragged_rank1, class_num]`. When we try to call one element for inspection/processing via` .take(1)` we get **input data** shapes `[1, singe_fixed_rank1, ragged_rank2, embedding_dim]`, so there is only one ragged rank. In this case, for the **target data**, the data shapes `[1, singe_fixed_rank1, class_num]`, which is not a ragged tensor.
After processing the **input data**, the model returns a RaggedTensor and the target is stay Tensor. An error occurs at the loss processing stage, which says that RaggedTensor and Tensor cannot be compared.
The simplest thing is to fix the data output in the `Dataset `class so that when `ragged=True`, all data sets are returned in shapes of a RaggedTensor, despite the absence of ragged_rank in any set.
The second option is to add a check to the loss calculation for the same sizes of RaggedTensor and Tensor before processing. Allow such losses to be calculated for tensors with identical shapes.
As typed in the start of topic, using `.map()` to fix Tensor to RaggedTensor  in target return the error... Yes, and I would not like to do manually something like this, because it will be very temporal solution due to a bag of tensorflow (by my  opinion) 
> The second option is to add a check to the loss calculation for the same sizes of RaggedTensor and Tensor before processing. Allow such losses to be calculated for tensors with identical shapes.

So, I would prefer to wait while this problem will be resolved on tensorflow side.  Hi @mihalt ,

Could you please submit a minimal code snippet with dummy data to replicate the reported issue? Thanks! ```
import tensorflow as tf

x = [
    [
        [0, 1, 2, 3],
    ],
    [
        [0, 1, 2],
        [0],
    ],
    [
        [0, 1, 2, 3, 4],
    ],
]
y = [
    [0],
    [1, 1],
    [2],
]

tokens = tf.data.Dataset.from_tensor_slices(tf.ragged.constant(x, dtype=tf.int32))
tags = tf.data.Dataset.from_tensor_slices(tf.ragged.constant(y, dtype=tf.int32))

ds = tf.data.Dataset.zip(tokens, tags)

print('--batch--')
print(ds.take(2))
a, b = ds.take(2)
print(a,b)

print('\n--element_iter--')
for element in ds:
    print(element)
```
console gave this^
--batch--
_<_TakeDataset element_spec=(RaggedTensorSpec(TensorShape([None, None]), tf.int32, 1, tf.int64), RaggedTensorSpec(TensorShape([None]), tf.int32, 0, tf.int64))>
(<tf.RaggedTensor [[0, 1, 2, 3]]>, <tf.**Tensor**: shape=(1,), dtype=int32, numpy=array([0])>) (<tf.RaggedTensor [[0, 1, 2], [0]]>, <tf.**Tensor**: shape=(2,), dtype=int32, numpy=array([1, 1])>)

--element_iter--
(<tf.RaggedTensor [[0, 1, 2, 3]]>, <tf.**Tensor**: shape=(1,), dtype=int32, numpy=array([0])>)
(<tf.RaggedTensor [[0, 1, 2], [0]]>, <tf.**Tensor**: shape=(2,), dtype=int32, numpy=array([1, 1])>)
(<tf.RaggedTensor [[0, 1, 2, 3, 4]]>, <tf.**Tensor**: shape=(1,), dtype=int32, numpy=array([2])>)_

So, only X become ragged, all Y is Tensor. Hi @mihalt ,

Thanks for repro snippet. I have replicated the issue and attached [gist](https://colab.sandbox.google.com/gist/SuryanarayanaY/4008a4dadbcb04149da51c472cf432ef/62655.ipynb). Need to check with SME for this behaviour.
### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

source

### TensorFlow version

2.14

### Custom code

Yes

### OS platform and distribution

_No response_

### Mobile device

_No response_

### Python version

_No response_

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

I can't use zipped dataset with Tensors as labels and RaggedTensors as tokens with this error. 

TypeError: Some of the inputs are not tf.RaggedTensor. Input received: [<tf.Tensor 'Cast_1:0' shape=(None, None) dtype=float32>, tf.RaggedTensor(values=Tensor("sequential_3/dense_8/Softmax:0", shape=(None, 15), dtype=float32), row_splits=Tensor("sequential_3/rnn_10/RaggedFromTensor/concat:0", shape=(None,), dtype=int64))]

### Standalone code to reproduce the issue

```shell
And I can't convert Tensors in dataset to Ragged through map due to error
ValueError: The rank of a RaggedTensor must be greater than 1, i.e., a list of scalars won't have ragged dimensions. Received argument `tensor` with rank 1.
```


### Relevant log output

_No response_