[SOLVED] Transfer function loading error


#1

Hello,

I’m experiencing an error whenever I try to load more than 1 transfer function in my NRP experiment. The error does not have any impact on the simulation at all. In the meantime, I am not sure whether this could be harmful for my experiment in the future. The error appears during the initialization of the experiment (or just after). It only happens when I load more than 1 transfer function. It goes as:

[ERROR] [1513770873.879224]: Error processing request: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

[‘Traceback (most recent call last):\n’, ’ File “/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py”, line 626, in _handle_request\n response = convert_return_to_response(self.handler(request), self.response_class)\n’, ’ File “/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py”, line 193, in convert_return_to_response\n elif response == None:\n’, ‘ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()\n’]

2017-12-20 12:54:33,878 [Thread-906 ] [rosout ] [ERROR] Error processing request: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

[‘Traceback (most recent call last):\n’, ’ File “/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py”, line 626, in _handle_request\n response = convert_return_to_response(self.handler(request), self.response_class)\n’, ’ File “/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py”, line 193, in convert_return_to_response\n elif response == None:\n’, ‘ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()\n’]

2017-12-20 12:54:33,880 [uWSGIWorker1] [hbp_nrp_back] [ERROR] Error executing service “/ros_cle_simulation/21/get_transfer_functions”, unable to communicate with the CLE.

Error: service [/ros_cle_simulation/21/get_transfer_functions] responded with an error: error processing request: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Anyone knows if this is a serious error, or if I can just ignore it?

Thank you very much for any idea or feedback!
Alban


#2

Hi Alban,

The specific error:

‘ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()\n’

means that you probably have a newer version of numpy on your Python path that does not work with ROS. This probably was installed to the system by some other pip package like tensorflow or something else. It could be that the one transfer function you are loading imports something else that imports a newer version of numpy.

If the simulation works fine then I guess you don’t have to worry about it, but I am pretty sure the NRP cannot function properly with that version of numpy loaded.

You can run pip show numpy to see what version you may have installed in your system libs, if it’s > 1.11 then that is probably the issue.

Kenny


#3

Awesome I downgraded numpy and the error vanished!

You rock… I saw on another post that you are going to leave the group. So: have a fun and successful continuation!!

All the best,
Alban


#4

Btw, does anyone remember where in the CLE code I can tell the brain simulator to use several cores? Or may be a cleaner way exists?
Thanks,
Alban
EDIT: actually you can call something like pynn.setup(…, threads=7)
or you may change the default setup in $HBP/CLE/hbp_nrp_cle/hbp_nrp_cle/brainsim/pynn/PyNNControlAdapter.py


#5

Yup, pynn.setup is the cleaner way to go since it will persist in the brain file if you share the experiment. The NRP will limit the number of threads to #cores - 1 on your machine for best performance, so you can safely distribute that with a high number to others with machines with fewer cores.

Thanks for the well wishes, good luck on your PhD!


#6

Thanks for all the advice, it was really precious :slight_smile:

For anyone else interested in the question: does anyone knows how to have multiple versions of numpy running on the NRP?

My problem is the following: the NRP backend needs python 1.11. But GPU support for theano only works for numpy version > 1.11. Does anyone knows if there is a way to tell theano to use a specific version of numpy and the NRP backend to use numpy 1.11?

The issue is that the theano being used by the NRP experiment is the one installed on the platform virtual environment. I am not very familiar with flags.

Thanks for any help!
Best,
Aban


#7

This error message is telling you that the boolean value of the entire array is unclear because it has multiple elements.

To resolve this ambiguity, NumPy provides two methods that can be used to determine the truth value of an array with multiple elements: a.any() and a.all().

  • a.any() : returns True if at least one element in the array a is True.
  • a.all() : returns True only if all the elements in the array a are True.

So, instead of using the array itself as a condition, you should use one of these methods to determine its truth value.