A ragged array (or jagged array) is an array of arrays. The elements of a ragged array can be of different dimensions and sizes.
Questions tagged [ragged]
78 questions
33
votes
4 answers
Pandas read_csv expects wrong number of columns, with ragged csv file
I have a csv file that has a few hundred rows and 26 columns, but the last few columns only have a value in a few rows and they are towards the middle or end of the file. When I try to read it in using read_csv() I get the following error.…

chrisfs
- 6,182
- 6
- 29
- 35
11
votes
1 answer
What's the workaround for "ragged/jagged tensors" in PyTorch?
Tensorflow provides ragged tensors (https://www.tensorflow.org/guide/ragged_tensor). PyTorch however doesn't provide such a data structure. Is there a workaround to construct something similar in PyTorch?
import numpy as np
x = np.array([[0], [0,…

Jensun Ravichandran
- 959
- 1
- 11
- 28
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
5
votes
1 answer
Does tf.keras.layers.Conv1D support RaggedTensor input?
In the tensorflow conv1D layer documentation, it says that;
'When using this layer as the first layer in a model, provide an
input_shape argument (tuple of integers or None, e.g. (10, 128) for
sequences of 10 vectors of 128-dimensional vectors,…

Arwen
- 168
- 1
- 13
5
votes
1 answer
How do you index a RaggedTensor along the ragged dimension, in TensorFlow?
I need to get values in a ragged tensor by indexing along the ragged dimension. Some indexing works ([:, :x], [:, -x:] or [:, x:y]), but not direct indexing ([:, x]):
R = tf.RaggedTensor.from_tensor([[1, 2, 3], [4, 5, 6]])
print(R[:, :2]) #…

MiniQuark
- 46,633
- 36
- 147
- 183
5
votes
1 answer
Is Julia's Vector{Vector{T}} stored contiguously in memory?
To motivate my question, consider the case when dealing with jagged arrays (for simplicity's sake) of element type Int in Julia. There are two ways to store them:
As Vector{Vector{Int}}
As Vector{Union{Vector{Int}, Int}} (especially, if one expects…

aberdysh
- 1,634
- 2
- 13
- 34
5
votes
5 answers
Splitting text column into ragged multiple new columns in a data table in R
I have a data table containing 20000+ rows and one column. The string in each column has different number of words. I want to split the words and put each of them in a new column. I know how I can do it word by word:
Data [ , Word1 :=…

user36729
- 545
- 5
- 30
4
votes
1 answer
How to forecast using ragged edge data in a MIDAS model using the MIDASR package?
I am trying to generate a 1-step-ahead forecast of a quarterly variable using a monthly variable with the midasr package. The trouble I am having is that I can only estimate a MIDAS model when the number of monthly observations in the sample is…

intern
- 43
- 4
4
votes
2 answers
Ragged array in C
I've been handed a microcontroller project that is in C. I am an accomplished programmer, but not in this language. I 'think' my problem is related to C syntax (and my lack of understanding) and not the microcontroller compiler, so I will ignore…

Cartoondog
- 105
- 1
- 8
3
votes
1 answer
How to reshape a ragged tensor?
Suppose you have stacked two sequences of 3-dimensional embeddings into a single ragged tensor:
import tensorflow as tf
def foo(*args):
n_elements = tf.reduce_prod(args)
return tf.range(n_elements, dtype=tf.float32).reshape(args)
c =…

Mike Land
- 436
- 4
- 15
3
votes
0 answers
How to mask logits for tf.softmax_cross_entropy_with_logits to implement valid actions
I want to compute the softmax_cross_entropy_with_logits of a batch tensor.
I have a batch of logits tensor as input, however I want to mask this tensor before with a boolean mask. The boolean mask is also a batch of masks, in every mask there can be…

superfuzzy
- 346
- 2
- 13
2
votes
1 answer
How to pre-pad tensorflow ragged tensor with beginning values
This question is similar to this question:
pad last dimension of tensor
with the exception that I would like to pre-pad this tensor with the beginning values. Given the ragged tensor:
[[1],
[4, 2],
[1, 2, 3]]
I would expect the output to be:
[[1…

d84_n1nj4
- 1,712
- 6
- 23
- 40
2
votes
1 answer
Append elements to Ragged tensors?
Can I append elements or extend in some way Ragged Tensors as I can do nested lists ?
In [158]: l=[[1,2],[3],[4,5,6]] …

sten
- 7,028
- 9
- 41
- 63
2
votes
1 answer
Using awkward1.Array for BDT
I want to implement a boosted decision tree for my analysis. But the entries in my array contain are of varying length, so the array is not convertible directly into numpy or pandas.
Is there any way to use existing ML libraries with awkward array?

AlexBaykov
- 33
- 3
2
votes
1 answer
Tesnorflow custom layer that loops over ragged tensor cannot be built
I am trying customize a layer in tensorflow. The layer has to take ragged tesnor with unidentified length as input. But the code is stuck when trying to build the layer. Even the simple code attached below could not work properly.
import tensorflow…

Jing
- 23
- 3