Skip to content
Discussion options

You must be logged in to vote

May you clarify what exactly you want to do?
Do you want to convert a x: list[list[ndarray]] with

assert (
len(x) == B and all(len(x[i]) == 2 * D for i in range(B)) and all(x[i][j].ndim == 3 for i in range(B) for j in range(2 * D))
and all(x[i][k].shape == x[j][k].shape for i in range(B) for j in range(B) for k in range(2 * D))
)

to y: list[ndarry] with

assert len(y) == 2 * D and all(y[i].ndim == 4 and y[i].shape[0] == B for i in range(2 * D))

And do you need to write into an exist y, or just need construct such an array?
Given such specification, I think it is natural to write a function similar to your version 3:
First transpose the nested list in python without manipulate array, which …

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by frmetz
Comment options

You must be logged in to vote
1 reply
@YouJiacheng
Comment options

Comment options

You must be logged in to vote
5 replies
@frmetz
Comment options

@YouJiacheng
Comment options

@frmetz
Comment options

@YouJiacheng
Comment options

@frmetz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants