How to parallelize a for in python inside a class?

随声附和 提交于 2019-12-01 22:17:07

Your problem is that the function you want to call is a instance method of an object. This can not be serialized and sent to another process. I see two solutions:

  1. use a different globally available function:

    class stabilize(BaseEstimator,TransformerMixin):
        ...
    def multiple_cv((self,o)):
        ...
    

    and

        self.mapper=p.map(self.multiple_cv,[(self, 1)]*self.sim)
    
  2. make the methods of objects serializable using VeryPicklableObject and its dependencies.

        @picklableInstancemethod
        def multiple_cv(self, o):
            ...
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!