0

I have a list named word_vector whose every element is of type 'numpy.ndarray'.

print(word_vector)

output:

[array([0., 0., 0., ..., 0., 0., 0.]), array([0., 0., 0., ..., 0., 0., 0.]), array([0., 0., 0., ..., 0., 0., 0.]), array([0., 0., 0., ..., 0., 0., 0.])]

I want to convert the type of each element of the list to list. So I wrote this code:

word_vector_list = []
for arr in word_vector:
    list_ = arr.tolist()
    word_vector_list.append(list_)
    
print(word_vector_list) 

The programming is getting hung repeatedly. I'm getting this exception:

IOPub data rate exceeded.
The notebook server will temporarily stop sending output
to the client in order to avoid crashing it.
To change this limit, set the config variable
`--NotebookApp.iopub_data_rate_limit`.

Current values:
NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)
NotebookApp.rate_limit_window=3.0 (secs)

length of each element(of type array) of the list is:

print(len(arr))

output:

4395
2
  • From the above data, the size seems to be just 4 x 4395. Have you tried converting just one nd array from the list and see how long does it take? Commented Jun 21, 2020 at 12:26
  • just tried for one element. It didn't get hung, but I've 10k * 4395 data. Commented Jun 21, 2020 at 12:31

2 Answers 2

1

I'm not entirely sure why your program is hanging. Try using list comprehension like so, it should be better:

word_vector_list = [list(x) for x in word_vector]

If it still didn't work, try increasing the iopub data rate. To increase the iopub data rate, run this in the terminal:

jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10

Hope this helps :)

Sign up to request clarification or add additional context in comments.

1 Comment

Problem persists even after increasing the data rate.
0

2d np array can be changed to list of lists directly by .tolist function.

Also seen here

Thanks

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.