Tuesday, February 22, 2011

Numpy Exceptions

To print all warnings in numpy do the following

import numpy as np
np.seterr(all='print')

This will print all warnings to stderr.

You can also make warnings to exceptions.
An example is shown below. The documentation is here.


import numpy

numpy.seterr(all='raise')

s = 10000.0

try:
    x = numpy.exp(s)
    print x
except:
    print "That is too big!"




No comments:

Post a Comment

Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1