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

    <bdo id='3qUs9'></bdo><ul id='3qUs9'></ul>
  • <legend id='3qUs9'><style id='3qUs9'><dir id='3qUs9'><q id='3qUs9'></q></dir></style></legend>

      <tfoot id='3qUs9'></tfoot>

      <small id='3qUs9'></small><noframes id='3qUs9'>

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

        delay() 函數(shù)有什么作用(在 Python 中與 joblib 一起使

        What does the delayed() function do (when used with joblib in Python)(delay() 函數(shù)有什么作用(在 Python 中與 joblib 一起使用時))

            <small id='0nI7B'></small><noframes id='0nI7B'>

            <legend id='0nI7B'><style id='0nI7B'><dir id='0nI7B'><q id='0nI7B'></q></dir></style></legend>

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

                  <tbody id='0nI7B'></tbody>

                1. <tfoot id='0nI7B'></tfoot>
                2. 本文介紹了delay() 函數(shù)有什么作用(在 Python 中與 joblib 一起使用時)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我已經(jīng)閱讀了 文檔,但我不明白這是什么意思:延遲函數(shù)是一個簡單的技巧,可以使用函數(shù)調(diào)用語法創(chuàng)建元組(函數(shù)、args、kwargs).

                  I've read through the documentation, but I don't understand what is meant by: The delayed function is a simple trick to be able to create a tuple (function, args, kwargs) with a function-call syntax.

                  我正在使用它來遍歷我想要操作的列表(allImages),如下所示:

                  I'm using it to iterate over the list I want to operate on (allImages) as follows:

                  def joblib_loop():
                      Parallel(n_jobs=8)(delayed(getHog)(i) for i in allImages)
                  

                  這會返回我想要的 HOG 功能(并使用我所有的 8 個內(nèi)核來提高速度),但我只是不確定它實(shí)際上在做什么.

                  This returns my HOG features, like I want (and with the speed gain using all my 8 cores), but I'm just not sure what it is actually doing.

                  我的 Python 知識充其量還可以,但我很可能缺少一些基本知識.任何指向正確方向的指針將不勝感激

                  My Python knowledge is alright at best, and it's very possible that I'm missing something basic. Any pointers in the right direction would be most appreciated

                  推薦答案

                  如果我們看看如果我們簡單地寫會發(fā)生什么事情會變得更清楚

                  Perhaps things become clearer if we look at what would happen if instead we simply wrote

                  Parallel(n_jobs=8)(getHog(i) for i in allImages)
                  

                  在這種情況下,可以更自然地表達(dá)為:

                  which, in this context, could be expressed more naturally as:

                  1. 使用 n_jobs=8
                  2. 創(chuàng)建一個 Parallel 實(shí)例
                  3. 創(chuàng)建列表[getHog(i) for i in allImages]
                  4. 將該列表傳遞給 Parallel 實(shí)例
                  1. Create a Parallel instance with n_jobs=8
                  2. create the list [getHog(i) for i in allImages]
                  3. pass that list to the Parallel instance

                  有什么問題?當(dāng)列表被傳遞給 Parallel 對象時,所有 getHog(i) 調(diào)用都已經(jīng)返回 - 所以沒有任何東西可以并行執(zhí)行!所有的工作都已經(jīng)在主線程中按順序完成了.

                  What's the problem? By the time the list gets passed to the Parallel object, all getHog(i) calls have already returned - so there's nothing left to execute in Parallel! All the work was already done in the main thread, sequentially.

                  我們實(shí)際上想要的是告訴Python我們想用什么參數(shù)調(diào)用什么函數(shù),沒有實(shí)際調(diào)用它們——換句話說,我們想要延遲執(zhí)行.

                  What we actually want is to tell Python what functions we want to call with what arguments, without actually calling them - in other words, we want to delay the execution.

                  這是 delayed 方便我們做的事情,語法清晰.如果我們想告訴 Python 我們想稍后調(diào)用 foo(2, g=3),我們可以簡單地寫成 delayed(foo)(2, g=3).返回的是元組 (foo, [2], {g: 3}),包含:

                  This is what delayed conveniently allows us to do, with clear syntax. If we want to tell Python that we'd like to call foo(2, g=3) sometime later, we can simply write delayed(foo)(2, g=3). Returned is the tuple (foo, [2], {g: 3}), containing:

                  • 對我們要調(diào)用的函數(shù)的引用,例如foo
                  • 所有參數(shù)(簡稱args")不帶關(guān)鍵字,例如2
                  • 所有關(guān)鍵字參數(shù)(簡稱kwargs"),例如g=3
                  • a reference to the function we want to call, e.g.foo
                  • all arguments (short "args") without a keyword, e.g.t 2
                  • all keyword arguments (short "kwargs"), e.g. g=3

                  因此,通過編寫 Parallel(n_jobs=8)(delayed(getHog)(i) for i in allImages),而不是上面的順序,現(xiàn)在會發(fā)生以下情況:

                  So, by writing Parallel(n_jobs=8)(delayed(getHog)(i) for i in allImages), instead of the above sequence, now the following happens:

                  1. 創(chuàng)建了具有 n_jobs=8Parallel 實(shí)例

                  名單

                   [delayed(getHog)(i) for i in allImages]
                  

                  被創(chuàng)建,評估為

                   [(getHog, [img1], {}), (getHog, [img2], {}), ... ]
                  

                3. 該列表被傳遞給 Parallel 實(shí)例

                  Parallel 實(shí)例創(chuàng)建 8 個線程并將列表中的元組分配給它們

                  The Parallel instance creates 8 threads and distributes the tuples from the list to them

                  最后,這些線程中的每一個都開始執(zhí)行元組,即,它們調(diào)用第一個元素,并將第二個和第三個元素解包為參數(shù) tup[0](*tup[1], **tup[2]),將元組轉(zhuǎn)回我們真正想要做的調(diào)用,getHog(img2).

                  Finally, each of those threads starts executing the tuples, i.e., they call the first element with the second and the third elements unpacked as arguments tup[0](*tup[1], **tup[2]), turning the tuple back into the call we actually intended to do, getHog(img2).

                  這篇關(guān)于delay() 函數(shù)有什么作用(在 Python 中與 joblib 一起使用時)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!
                4. 相關(guān)文檔推薦

                  What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                  Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數(shù)傳遞給 pool.map() 函數(shù))
                  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 多進(jìn)程池.當(dāng)其中一個工作進(jìn)程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                  How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊(duì)列引用傳遞給 pool.map_async() 管理的函數(shù)?)
                  yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)
                    <tbody id='n3XFM'></tbody>
                    <legend id='n3XFM'><style id='n3XFM'><dir id='n3XFM'><q id='n3XFM'></q></dir></style></legend>

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

                      1. <small id='n3XFM'></small><noframes id='n3XFM'>

                          <bdo id='n3XFM'></bdo><ul id='n3XFM'></ul>

                            <tfoot id='n3XFM'></tfoot>
                          1. 主站蜘蛛池模板: 一区二区三区亚洲 | 国产亚洲网站 | 日韩在线看片 | 亚洲精品中文在线 | 国产 日韩 欧美 制服 另类 | 韩国精品一区二区三区 | 日本 欧美 三级 高清 视频 | 91精品国产综合久久久久久蜜臀 | 日韩欧美在线视频播放 | 爱爱无遮挡 | 久久69精品久久久久久久电影好 | 国产精品美女久久久久 | 国产精品久久久久久久久久妞妞 | 欧美一区在线视频 | 中文字幕一区二区三区四区五区 | 欧美一区二区三区四区视频 | 久久一二 | 少妇一级淫片aaaaaaaaa | v亚洲| 国产精品一区二区三区在线 | 日韩和的一区二在线 | 免费在线观看av | 国产欧美视频一区 | 91在线视频网址 | 亚洲欧洲激情 | 爱爱视频在线观看 | 久久久久久成人 | 亚洲国产精品一区二区第一页 | 九九亚洲 | 久久激情视频 | 一区二区三区欧美 | 精品视频一区二区 | 国产精品1区2区 | 亚洲精品久久久 | 999www视频免费观看 | 日韩在线一区二区三区 | 国产美女视频 | 成人在线小视频 | 欧美激情va永久在线播放 | 爱爱视频在线观看 | 在线第一页 |