pytorch torch.nn.AdaptiveAvgPool2d()自適應(yīng)平均池化函數(shù)詳解
如題:只需要給定輸出特征圖的大小就好,其中通道數(shù)前后不發(fā)生變化。具體如下:
AdaptiveAvgPool2d
CLASStorch.nn.AdaptiveAvgPool2d(output_size)[SOURCE]
Applies a 2D adaptive average pooling over an input signal composed of several input planes.
The output is of size H x W, for any input size. The number of output features is equal to the number of input planes.
Parameters
output_size – the target output size of the image of the form H x W. Can be a tuple (H, W) or a single H for a square image H x H. H and W can be either a int, or None which means the size will be the same as that of the input.
Examples
>>> # target output size of 5x7 >>> m = nn.AdaptiveAvgPool2d((5,7)) >>> input = torch.randn(1, 64, 8, 9) >>> output = m(input) >>> # target output size of 7x7 (square) >>> m = nn.AdaptiveAvgPool2d(7) >>> input = torch.randn(1, 64, 10, 9) >>> output = m(input) >>> # target output size of 10x7 >>> m = nn.AdaptiveMaxPool2d((None, 7)) >>> input = torch.randn(1, 64, 10, 9) >>> output = m(input)
>>> input = torch.randn(1, 3, 3, 3) >>> input tensor([[[[ 0.6574, 1.5219, -1.3590], [-0.1561, 2.7337, -1.8701], [-0.8572, 1.0238, -1.9784]], [[ 0.4284, 1.4862, 0.3352], [-0.7796, -0.8020, -0.1243], [-1.2461, -1.7069, 0.1517]], [[ 1.4593, -0.1287, 0.5369], [ 0.6562, 0.0616, 0.2611], [-1.0301, 0.4097, -1.9269]]]]) >>> m = nn.AdaptiveAvgPool2d((2, 2)) >>> output = m(input) >>> output tensor([[[[ 1.1892, 0.2566], [ 0.6860, -0.0227]], [[ 0.0833, 0.2238], [-1.1337, -0.6204]], [[ 0.5121, 0.1827], [ 0.0243, -0.2986]]]]) >>> 0.6574+1.5219+2.7337-0.1561 4.7569 >>> 4.7569/4 1.189225 >>>
以上這篇pytorch torch.nn.AdaptiveAvgPool2d()自適應(yīng)平均池化函數(shù)詳解就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Python 中由 yield 實(shí)現(xiàn)異步操作
這篇文章主要介紹了Python 中由 yield 實(shí)現(xiàn)異步操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-05-05使用Python設(shè)置Excel單元格數(shù)字的顯示格式
Python語(yǔ)言可以幫助我們靈活設(shè)置Excel單元格的數(shù)字格式,保證數(shù)據(jù)的一致性與專業(yè)標(biāo)準(zhǔn),本文將介紹如何使用Python對(duì)Excel工作表中單元格的數(shù)字格式進(jìn)行設(shè)置,文中通過(guò)代碼示例介紹的非常詳細(xì),需要的朋友可以參考下2024-06-06在前女友婚禮上,用Python破解了現(xiàn)場(chǎng)的WIFI還把名稱改成了
今日重點(diǎn):① python暴力拿下WiFi密碼,②python拿下路由器管理頁(yè)面,文中有非常詳細(xì)的代碼示例,干貨滿滿,,需要的朋友可以參考下2021-05-05Django實(shí)現(xiàn)靜態(tài)文件緩存到云服務(wù)的操作方法
這篇文章主要介紹了Django實(shí)現(xiàn)靜態(tài)文件緩存到云服務(wù)的操作方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08Python技巧之實(shí)現(xiàn)批量統(tǒng)一圖片格式和尺寸
大家在工作的時(shí)候基本都會(huì)接觸到很多的圖片,有時(shí)為了不同的工作需求需要修改圖片的尺寸或者大小。本文為大家整理了Python批量轉(zhuǎn)換圖片格式和統(tǒng)一圖片尺寸,希望對(duì)大家有所幫助2023-05-05Python實(shí)現(xiàn)圖片指定位置加圖片水?。ǜ絇yinstaller打包exe)
這篇文章主要介紹了Python實(shí)現(xiàn)圖片指定位置加圖片水印,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03詳解pyppeteer(python版puppeteer)基本使用
這篇文章主要介紹了詳解pyppeteer(python版puppeteer)基本使用 ,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06Python pandas讀取CSV文件的注意事項(xiàng)(適合新手)
這篇文章主要給大家介紹了關(guān)于Python pandas讀取CSV文件的注意事項(xiàng),非常適合新手,csv是我接觸的比較早的一種文件,比較好的是這種文件既能夠以電子表格的形式查看又能夠以文本的形式查看,需要的朋友可以參考下2021-06-06