1 year ago
#374794
Sina Baghali
Convert a list of cupy array to comination of list
I have a list of cupy.array as follow,
X_train = [[[cp.array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]),
cp.array([0.96376295, 0.4473439 ])]],
[[cp.array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]),
cp.array([0.08592631, 0.74990236])]]]
I want to change this list to this:
[[array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]),
array([0.96376295, 0.4473439 ])],
[array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]),
array([0.08592631, 0.74990236])]]
With numpy in cpu, I know that it solves with:
X_train = np.array(X_train)
X_train = [X_train.tolist() for arr in X_train for X_train in arr]
However, with cupy in GPU, I don't know how to solve that. It seems that it is different. Based on this link: creatiing a cupy array from python list is slow
python
gpu
cupy
0 Answers
Your Answer