久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='Zs7Ey'></bdo><ul id='Zs7Ey'></ul>
  1. <i id='Zs7Ey'><tr id='Zs7Ey'><dt id='Zs7Ey'><q id='Zs7Ey'><span id='Zs7Ey'><b id='Zs7Ey'><form id='Zs7Ey'><ins id='Zs7Ey'></ins><ul id='Zs7Ey'></ul><sub id='Zs7Ey'></sub></form><legend id='Zs7Ey'></legend><bdo id='Zs7Ey'><pre id='Zs7Ey'><center id='Zs7Ey'></center></pre></bdo></b><th id='Zs7Ey'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Zs7Ey'><tfoot id='Zs7Ey'></tfoot><dl id='Zs7Ey'><fieldset id='Zs7Ey'></fieldset></dl></div>

    <small id='Zs7Ey'></small><noframes id='Zs7Ey'>

    <tfoot id='Zs7Ey'></tfoot>

    <legend id='Zs7Ey'><style id='Zs7Ey'><dir id='Zs7Ey'><q id='Zs7Ey'></q></dir></style></legend>

    1. Python 多處理 Numpy 隨機

      Python Multiprocessing Numpy Random(Python 多處理 Numpy 隨機)

          <bdo id='2F2Na'></bdo><ul id='2F2Na'></ul>
          <legend id='2F2Na'><style id='2F2Na'><dir id='2F2Na'><q id='2F2Na'></q></dir></style></legend>

              <tfoot id='2F2Na'></tfoot>
              <i id='2F2Na'><tr id='2F2Na'><dt id='2F2Na'><q id='2F2Na'><span id='2F2Na'><b id='2F2Na'><form id='2F2Na'><ins id='2F2Na'></ins><ul id='2F2Na'></ul><sub id='2F2Na'></sub></form><legend id='2F2Na'></legend><bdo id='2F2Na'><pre id='2F2Na'><center id='2F2Na'></center></pre></bdo></b><th id='2F2Na'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2F2Na'><tfoot id='2F2Na'></tfoot><dl id='2F2Na'><fieldset id='2F2Na'></fieldset></dl></div>

                  <tbody id='2F2Na'></tbody>
              1. <small id='2F2Na'></small><noframes id='2F2Na'>

                本文介紹了Python 多處理 Numpy 隨機的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                在多處理調用的函數中,numpy ndarray 函數的范圍是否不同?這是一個例子:

                Does the scope of a numpy ndarray function differently within a function called by multiprocessing? Here is an example:

                使用 python 的多處理模塊我正在調用這樣的函數:

                Using python's multiprocessing module I am calling a function like so:

                for core in range(cores):
                    #target could be f() or g()
                    proc = mp.Process(target=f, args=(core))
                    jobs.append(proc)
                for job in jobs:
                    job.start()
                for job in jobs:
                    job.join()
                
                def f(core):
                    x = 0
                    x += random.randint(0,10)
                    print x
                
                def g(core):
                    #Assume an array with 4 columns and n rows
                    local = np.copy(globalshared_array[:,core])
                    shuffled = np.random.permutation(local)
                

                調用f(core)x變量是進程本地的,即.它按預期打印一個不同的隨機整數.這些從不超過 10,表明 x=0 在每個進程中.對嗎?

                Calling f(core), the x variable is local to the process, ie. it prints a different, random integer as expected. These never exceed 10, indicating that x=0 in each process. Is that correct?

                調用 g(core) 并排列數組的副本會返回 4 個完全相同的混洗"數組.這似乎表明工作副本不是子進程的本地.那是對的嗎?如果是這樣,除了使用共享內存空間之外,當需要從共享內存空間填充時,是否可以將 ndarray 放在子進程的本地?

                Calling g(core) and permuting a copy of the array returns 4 identically 'shuffled' arrays. This seems to indicate that the working copy is not local the child process. Is that correct? If so, other than using sharedmemory space, is it possible to have an ndarray be local to the child process when it needs to be filled from shared memory space?

                更改 g(core) 以添加隨機整數似乎具有預期的效果.數組顯示不同的值.permutation 中一定發生了一些事情,隨機排列列(每個子進程的本地)相同...想法?

                Altering g(core) to add a random integer appears to have the desired effect. The array's show a different value. Something must be occurring in permutation that is randomly ordering the columns (local to each child process) the same...ideas?

                def g(core):
                    #Assume an array with 4 columns and n rows
                    local = np.copy(globalshared_array[:,core])
                    local += random.randint(0,10)
                

                編輯二:np.random.shuffle 也表現出相同的行為.數組的內容正在洗牌,但在每個核心上都洗牌到相同的值.

                EDIT II: np.random.shuffle also exhibits the same behavior. The contents of the array are shuffling, but are shuffling to the same value on each core.

                推薦答案

                調用 g(core) 并排列數組的副本會返回 4 個完全相同的混洗"數組.這似乎表明工作副本不是子進程的本地.

                Calling g(core) and permuting a copy of the array returns 4 identically 'shuffled' arrays. This seems to indicate that the working copy is not local the child process.

                這可能表明隨機數生成器在每個子進程中的初始化相同,產生相同的序列.您需要為每個孩子的生成器播種(也許將孩子的進程 id 混入其中).

                What it likely indicates is that the random number generator is initialized identically in each child process, producing the same sequence. You need to seed each child's generator (perhaps throwing the child's process id into the mix).

                這篇關于Python 多處理 Numpy 隨機的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數傳遞給 pool.map() 函數)
                multiprocessing.pool.MaybeEncodingError: #39;TypeError(quot;cannot serialize #39;_io.BufferedReader#39; objectquot;,)#39;(multiprocessing.pool.MaybeEncodingError: TypeError(cannot serialize _io.BufferedReader object,)) - IT屋-程序員軟件開
                Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?(Python 多進程池.當其中一個工作進程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數?)
                yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)

                  <small id='PryQC'></small><noframes id='PryQC'>

                1. <legend id='PryQC'><style id='PryQC'><dir id='PryQC'><q id='PryQC'></q></dir></style></legend>
                2. <tfoot id='PryQC'></tfoot>
                    <bdo id='PryQC'></bdo><ul id='PryQC'></ul>
                      <tbody id='PryQC'></tbody>

                      <i id='PryQC'><tr id='PryQC'><dt id='PryQC'><q id='PryQC'><span id='PryQC'><b id='PryQC'><form id='PryQC'><ins id='PryQC'></ins><ul id='PryQC'></ul><sub id='PryQC'></sub></form><legend id='PryQC'></legend><bdo id='PryQC'><pre id='PryQC'><center id='PryQC'></center></pre></bdo></b><th id='PryQC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PryQC'><tfoot id='PryQC'></tfoot><dl id='PryQC'><fieldset id='PryQC'></fieldset></dl></div>
                        • 主站蜘蛛池模板: 大陆一级毛片免费视频观看 | 在线综合视频 | 在线一区二区三区 | 欧美日韩不卡在线 | 在线永久看片免费的视频 | 国产sm主人调教女m视频 | 国产美女h视频 | 一级黄色片网址 | 在线视频中文字幕 | 国产一区 在线视频 | 日韩精品一区二区三区在线播放 | 二区在线视频 | 亚洲网址| 久久99一区二区 | 国产激情免费视频 | 久久久入口 | 乱码av午夜噜噜噜噜动漫 | 日韩成人专区 | 国产激情免费视频 | 久久综合久色欧美综合狠狠 | 日本天天操 | 91大神在线看 | 91精品中文字幕一区二区三区 | 久久久久久国模大尺度人体 | 91av在线免费| 一级毛片在线播放 | 91人人视频在线观看 | 国产精品亚洲精品日韩已方 | 国产99小视频 | 日韩精品久久久久久 | 亚洲va中文字幕 | 国产99视频精品免视看9 | 国产精品区二区三区日本 | 久久精品国产清自在天天线 | 国产线视频精品免费观看视频 | 日韩在线播放网址 | 日本网站免费在线观看 | 亚洲福利网 | 国产精品久久二区 | 久久久久久久久久久久久久久久久久久久 | 久久中文字幕一区 |