Created
October 23, 2014 04:13
-
-
Save wenhoujx/89ae39d41e0ebb869664 to your computer and use it in GitHub Desktop.
joblib_tut01
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
import joblib as jl | |
import numpy as np | |
import os | |
def sum_row(xx): | |
"""sum xx | |
:xx: a vector | |
:returns: a summed float | |
""" | |
print os.getpid() | |
return np.sum(xx) | |
x = np.random.random((10, 10000)) | |
sumed_x = jl.Parallel(n_jobs=-1)( | |
jl.delayed(sum_row)(xx) for xx in x) | |
print sumed_x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment