Last active
August 29, 2015 14:17
-
-
Save ccwang002/0f25f2dd4b59312925a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
rs = np.random.RandomState(seed=5566) | |
n_conditions = 10 | |
# Here we simulate a complex computation, for example, analogy of the magnitude | |
# of gradient decent which expects to be strictly positive. But from the result | |
# we find that it seems to be sometimes negative, we wish to find out when and | |
# what condition our program produces bogus ouput. | |
# | |
# This is the case to use pdb and condition break point | |
result_sum = 0.0 | |
# To enable pdb debug, uncomment the following two lines: | |
# | |
# import pdb | |
# pdb.Pdb(skip=['numpy.*']).set_trace() | |
# | |
# setting skip=['some modules'] so we could use 's' (step) into our own code | |
# instead of debugging every module we use. | |
for i in range(n_conditions): | |
complex_out = rs.normal(loc=3.0, scale=0.8, size=1000) | |
# we found the result is not right sometimes | |
result_sum += np.sum(complex_out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment