Questions tagged [ragged-tensors]
44 questions
8
votes
2 answers
Broadcast and concatenate ragged tensors
I have a ragged tensor of dimensions [BATCH_SIZE, TIME_STEPS, EMBEDDING_DIM]. I want to augment the last axis with data from another tensor of shape [BATCH_SIZE, AUG_DIM]. Each time step of a given example gets augmented with the same value.
If the…

JuliettVictor
- 614
- 5
- 14
3
votes
1 answer
Ragged Tensors have no len() after conversion to Tensor
I am training a deep learning model on stacks of images with variable dimensions. (Shape = [Batch, None, 256, 256, 1]), where None can be variable.
I use tf.RaggedTensor.merge_dimsions(0,1) to convert the ragged Tensor to a shape of [None, 256,…

Wayne
- 31
- 2
3
votes
0 answers
RaggedTensor on TPU
I am trying to train a neural network using TensorFlow that takes as input (tf.keras.layers.Input) a RaggedTensor. It works fine on CPU and GPU but I am really strugling to make it work on TPU. I wanted to know if some of you managed to make it work…

Vince.Bdn
- 1,145
- 1
- 13
- 28
2
votes
1 answer
Tensorflow dataset with variable number of elements
I need a dataset structured to handle a variable number of input images (a set of images) to regress against an integer target variable.
The code I am using to source the images is like this:
import tensorflow as tf
from tensorflow import…

Alberto
- 467
- 3
- 16
2
votes
0 answers
How to provide two inputs to a Tensorflow Model using ragged tensors?
I am trying to create a model with two inputs. The model is very simple containing only one lstm layer for each input. The problem is that I want to provide lists of different length as inputs. For that, I am using ragged tensors, but the training…

psitronic
- 21
- 2
2
votes
0 answers
'RaggedTensor' object has no attribute 'set_shape' when passing RaggedTensor to BatchNormalization layer in Tensorflow 2.8
I am trying to pass a 3D RaggedTensor of shape (batch_size=None, 1, 136) to a batch normalization layer, but am receiving the error in the title. I assume because RaggedTensors can very in dimensions, and thus have no set_shape() method as it would…

Jage
- 453
- 2
- 9
2
votes
2 answers
RaggedTensor request to TensorFlow serving fails
I've created a TensorFlow model that uses RaggedTensors. Model works fine and when calling model.predict and I get the expected results.
input = tf.ragged.constant([[[-0.9984272718429565, -0.9422321319580078, -0.27657580375671387,…

Shlomi Schwartz
- 8,693
- 29
- 109
- 186
1
vote
0 answers
How to feed Images of different size being into the CNN
The problem being solved is a binary classification using CNN. Here I have images of different size. I am scaled down the images to 20% and normalizing them to the range (0,1) and obviously they still have different sizes. I am using x_train =…

Chetan
- 11
- 3
1
vote
1 answer
Correct way to iterate over Keras ragged tensor
I have an input Tensorflow ragged tensor structured like this [batch num_images width height channels] and I need to iterate over the dimension num_images to extract some features relevant for downstream applications.
Example code is the…

Alberto
- 467
- 3
- 16
1
vote
0 answers
Setting shape of RaggedTensor with Known Shape
I'm working with RaggedTensors to manipulate a dense tensor. Something like this :
out_left = tf.ragged.boolean_mask(input, index)
index = tf.math.logical_not(index)
out_right = tf.ragged.boolean_mask(input, index)
…

Liam F-A
- 135
- 11
1
vote
1 answer
strip and filter strings in ragged tensor
I would like learn if there is a decent and tensorflownic way to do follow conversion. Basically each string(row) as several words, and each word has a suffix like "%1", and goal is to strip string and only leave words with suffix value <= certain…

user1269298
- 717
- 2
- 8
- 26
1
vote
0 answers
Dense layer only supports RaggedTensors when the innermost dimension is non-ragged. Received: inputs.shape=(None, None, None)
I have a tf.data.dataset with 2 and 3 dimensional ragged tensors:
[
[1,2,3,4],
[5,6,7,8],
...
]
and [
[[1,2,3],
[4,5,6]
],
[[7,8,9],
[10,11,12],
...
]
]
I receive the error in the title when passing the…

Jage
- 453
- 2
- 9
1
vote
1 answer
how to pad sequences in a tensor slice dataset in TensorFlow?
I have a tensor slice dataset made from two ragged tensors.
tensor_a is like:
tensor_b is like:
(Same…

pieckannie
- 33
- 3
1
vote
1 answer
Sample from ragged tensor
I have a raggedTensor of row_lens going from 1 to up to 10k. I would like to select elements randomly from it with an upper limit on the number per row in a scalable way. Like in this example:
vect = [[1,2,3],[4,5][6],[7,8,9,10,11,12,13]]
limit =…

Nodiz
- 333
- 2
- 8
1
vote
1 answer
IndexError: Dimension out of range (expected to be in range of [-2, 1], but got 3)
I created a random function with the line below
x = torch.randn(4, 3)
and used the transpose function as shown here
torch.transpose(x, 0, 1)
I got the error line below. Who can assist with a solution
IndexError …

Lamosh
- 41
- 5