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
0
votes
1 answer
Pandas rows containing numpy ndarrays various shapes
I'd creating a Pandas DataFrame in which each particular (index, column) location can be a numpy ndarray of arbitrary shape, or even a simple number.
This works:
import numpy as np, pandas as pd
x = pd.DataFrame([[np.random.rand(100, 100, 20, 2),…

Basj
- 41,386
- 99
- 383
- 673
0
votes
1 answer
Tensorflow concat ragged tensor returning wrong shape
I need to concat two ragged tensors keeping the last dimension with a fixed size 2.
Checking model.output_shape I get the desired (None, None, 2). But when I call the model, I get (batch_size, None, None). How do I get the right shape?
Code:
import…

yolisses
- 136
- 2
- 9
0
votes
1 answer
How to index a numpy list of lists with a list of lists of boolean values?
Preface
I am currently using sklearn's Nearest Neighbors (NN) algorithm, and the output of a fitted model's method radius_neighbors returns an list of lists of radii representing the distance from every other observation in the dataset that is <= a…

Edward
- 1
0
votes
1 answer
Python: Is there a better way to work with ragged arrays than a list of arrays with dtype = object?
I am collecting time series data, which can be separated into "tasks" based on a particular target value. These tasks can be numbered based on the associated target. However, the lengths of data associated with each task will differ because it may…

Caroline
- 21
- 3
0
votes
2 answers
How to slice according to batch in the tensorflow array?
I have an array output and a id subject_ids.
output = [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]]]
subject_ids = [[0, 1], [1, 2], [0, 2]]
The numbers in ID represent the start and end positions respectively, and then I want to get the vector between…

wwwxinyu
- 11
- 3
0
votes
1 answer
multiprocessing.Pool sharing large lists of lists read-only in memory across child process
I'm strungling with this problem.
I have a big list of lists that I want to acess with parallel code to perform CPU intensive operations. In order to do that i'm trying to use multiprocessing.Pool, the problem is that I also need to see this…

Patrick Nasser
- 13
- 4
0
votes
1 answer
Concatenate ragged inputs in Keras
The following code creates a dummy model that concatenate 2 inputs. One input is used with an Embedding layer with output size of 5, while the second input is just merged with the output of the Embedding layer:
import tensorflow as tf
import numpy…

Shlomi Schwartz
- 8,693
- 29
- 109
- 186
0
votes
0 answers
How to transform a list of 2D-arrays (with one dimension varies) to a ragged tensor?
x is a list of 2D-arrays, and each 2D-array is a series of 6-tuple.
I want to transform x into a ragged tensor. I try
xrag = tf.ragged.constant(x) and
get xrag with shape = (895, None, None), however its shape should be (895, None, 6). Would it be…

thanksarose
- 19
- 4
0
votes
1 answer
Unnest ragged tensor in tensorflow
I have following tf.RaggedTensor rt:
here is the dense version:
array([[[ 7592, 0, 0],
[ 0, 0, 0],
…

Frederik Bode
- 2,632
- 1
- 10
- 17
0
votes
1 answer
Create a jagged/ragged array in Python using classes and methods
I need to create a ragged two dimensional grid in Python which has 3 rows where the 1st row has 3 columns, 2nd row - 6 columns and 3rd row - 9 columns. All that should be done without using any packages like NumPy or anything else, only with classes…

Dima
- 3
- 2
0
votes
0 answers
How to convert python 3d list to ragged tensor in tensorflow?
I am using the following code:
def ragged_from_3Dlist(list3d):
values = [item for list2d in list3d for list1d in list2d for item in list1d]
lens2d = [len(list1d) for list2d in list3d for list1d in list2d]
lens1d = [len(list2d) for list2d…

Andrey
- 5,932
- 3
- 17
- 35
0
votes
1 answer
How to create tensorflow RaggedTensor from python list?
I have two-dimensional list (list of lists). I would like to create RaggedTensor from it.
But here is no method to create RaggedTensor from python list.
How to do it ?

Andrey
- 5,932
- 3
- 17
- 35
0
votes
1 answer
Is there an alternative, vectored way to write the to_array function?
Suppose we have a ragged, nested sequence like the following:
import numpy as np
x = np.ones((10, 20))
y = np.zeros((10, 20))
a = [[0, x], [y, 1]]
and want to create a full numpy array that broadcasts the ragged sub-sequences (to match the maximum…

user76284
- 1,269
- 14
- 29
0
votes
0 answers
Can we initialise a numpy array of numpy arrays with different shapes using some constructor?
I want an array that looks like this,
array([array([[1, 1], [2, 2]]), array([3, 3])], dtype=object)
I can make an empty array and then assign elements one by one like this,
z = [np.array([[1,1],[2,2]]), np.array([3,3])]
x = np.empty(shape=2,…

scribe
- 673
- 2
- 6
- 17
0
votes
0 answers
Working with variable dimension tensors in tensorflow
I want to build a tensor placeholder, features with dimension, say (10, a, a). Such that features[i, :, :] can be an arbitrary square tensor. As an instance, features[0. :, :] may be of dimension 5*5, and features[1, :, :] can be of dimension 8*8 at…