Passing Ragged Tensors for Training
Keras Makes Ragged Tensors Easy for Training with:
- Set the
ragged=True
argument: When defining the input layer usingtf.keras.Input
, set theragged=True
argument. This tells Keras the input will be a ragged tensor. - Pass your ragged tensor directly: After setting
ragged=True
, simply pass your ragged tensor as the input to the model. Keras handles the ragged structure internally.
inputs = keras.Input(shape=(), dtype=tf.int64, ragged=True)
Ragged tensors in TensorFlow
Ragged tensors are a fundamental data structure in TensorFlow, especially in scenarios where data doesn’t conform to fixed shapes, such as sequences of varying lengths or nested structures. In this article, we’ll understand what ragged tensors are, why they’re useful, and provide hands-on coding examples to illustrate their usage.
Table of Content
- What are Ragged Tensors?
- Why Use Ragged Tensors?
- Constructing Ragged Tensors
- Operations on Ragged Tensors
- Passing Ragged Tensors for Training