Skip to content

Instantly share code, notes, and snippets.

@wenhoujx
Created October 23, 2014 04:13
Show Gist options
  • Save wenhoujx/89ae39d41e0ebb869664 to your computer and use it in GitHub Desktop.
Save wenhoujx/89ae39d41e0ebb869664 to your computer and use it in GitHub Desktop.
joblib_tut01
#!/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