最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python神經(jīng)網(wǎng)絡(luò)MobileNetV3?large模型的復(fù)現(xiàn)詳解

 更新時(shí)間:2022年05月07日 10:49:44   作者:Bubbliiiing  
這篇文章主要為大家介紹了python神經(jīng)網(wǎng)絡(luò)MobileNetV3?large模型的復(fù)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

什么是MobileNetV3

為了防止某位我的粉絲寒假?zèng)]有辦法正常工作,我趕緊看了看MobilenetV3

最新的MobileNetV3的被寫在了論文《Searching for MobileNetV3》中。

它是mobilnet的最新版,據(jù)說效果還是很好的。

作為一種輕量級(jí)網(wǎng)絡(luò),它的參數(shù)量還是一如既往的小。

它綜合了以下四個(gè)特點(diǎn):

1、MobileNetV1的深度可分離卷積(depthwise separable convolutions)。

2、MobileNetV2的具有線性瓶頸的逆殘差結(jié)構(gòu)(the inverted residual with linear bottleneck)。

3、輕量級(jí)的注意力模型。

4、利用h-swish代替swish函數(shù)。

代碼下載

MobileNetV3(large)的網(wǎng)絡(luò)結(jié)構(gòu)

1、MobileNetV3(large)的整體結(jié)構(gòu)

如何看懂這個(gè)表呢?我們從每一列出發(fā):

第一列Input代表mobilenetV3每個(gè)特征層的shape變化;

第二列Operator代表每次特征層即將經(jīng)歷的block結(jié)構(gòu),我們可以看到在MobileNetV3中,特征提取經(jīng)過了許多的bneck結(jié)構(gòu);

第三、四列分別代表了bneck內(nèi)逆殘差結(jié)構(gòu)上升后的通道數(shù)、輸入到bneck時(shí)特征層的通道數(shù)。

第五列SE代表了是否在這一層引入注意力機(jī)制。

第六列NL代表了激活函數(shù)的種類,HS代表h-swish,RE代表RELU。

第七列s代表了每一次block結(jié)構(gòu)所用的步長(zhǎng)。

2、MobileNetV3特有的bneck結(jié)構(gòu)

bneck結(jié)構(gòu)如下圖所示:

它綜合了以下四個(gè)特點(diǎn):

a、MobileNetV2的具有線性瓶頸的逆殘差結(jié)構(gòu)(the inverted residual with linear bottleneck)。

即先利用1x1卷積進(jìn)行升維度,再進(jìn)行下面的操作,并具有殘差邊。

b、MobileNetV1的深度可分離卷積(depthwise separable convolutions)。

在輸入1x1卷積進(jìn)行升維度后,進(jìn)行3x3深度可分離卷積。

c、輕量級(jí)的注意力模型。

這個(gè)注意力機(jī)制的作用方式是調(diào)整每個(gè)通道的權(quán)重。

d、利用h-swish代替swish函數(shù)。

在結(jié)構(gòu)中使用了h-swishj激活函數(shù),代替swish函數(shù),減少運(yùn)算量,提高性能。

網(wǎng)絡(luò)實(shí)現(xiàn)代碼

由于keras代碼沒有預(yù)訓(xùn)練權(quán)重,所以只是把網(wǎng)絡(luò)結(jié)構(gòu)po出來。

from keras.layers import Conv2D, DepthwiseConv2D, Dense, GlobalAveragePooling2D,Input
from keras.layers import Activation, BatchNormalization, Add, Multiply, Reshape
from keras.models import Model
from keras import backend as K
alpha = 1
def relu6(x):
    # relu函數(shù)
    return K.relu(x, max_value=6.0)
def hard_swish(x):
    # 利用relu函數(shù)乘上x模擬sigmoid
    return x * K.relu(x + 3.0, max_value=6.0) / 6.0
def return_activation(x, nl):
    # 用于判斷使用哪個(gè)激活函數(shù)
    if nl == 'HS':
        x = Activation(hard_swish)(x)
    if nl == 'RE':
        x = Activation(relu6)(x)
    return x
def conv_block(inputs, filters, kernel, strides, nl):
    # 一個(gè)卷積單元,也就是conv2d + batchnormalization + activation
    channel_axis = 1 if K.image_data_format() == 'channels_first' else -1
    x = Conv2D(filters, kernel, padding='same', strides=strides)(inputs)
    x = BatchNormalization(axis=channel_axis)(x)
    return return_activation(x, nl)
def squeeze(inputs):
    # 注意力機(jī)制單元
    input_channels = int(inputs.shape[-1])
    x = GlobalAveragePooling2D()(inputs)
    x = Dense(int(input_channels/4))(x)
    x = Activation(relu6)(x)
    x = Dense(input_channels)(x)
    x = Activation(hard_swish)(x)
    x = Reshape((1, 1, input_channels))(x)
    x = Multiply()([inputs, x])
    return x
def bottleneck(inputs, filters, kernel, up_dim, stride, sq, nl):
    channel_axis = 1 if K.image_data_format() == 'channels_first' else -1
    input_shape = K.int_shape(inputs)
    tchannel = int(up_dim)
    cchannel = int(alpha * filters)
    r = stride == 1 and input_shape[3] == filters
    # 1x1卷積調(diào)整通道數(shù),通道數(shù)上升
    x = conv_block(inputs, tchannel, (1, 1), (1, 1), nl)
    # 進(jìn)行3x3深度可分離卷積
    x = DepthwiseConv2D(kernel, strides=(stride, stride), depth_multiplier=1, padding='same')(x)
    x = BatchNormalization(axis=channel_axis)(x)
    x = return_activation(x, nl)
    # 引入注意力機(jī)制
    if sq:
        x = squeeze(x)
    # 下降通道數(shù)
    x = Conv2D(cchannel, (1, 1), strides=(1, 1), padding='same')(x)
    x = BatchNormalization(axis=channel_axis)(x)
    if r:
        x = Add()([x, inputs])
    return x
def MobileNetv3_large(shape = (224,224,3),n_class = 1000):
    inputs = Input(shape)
    # 224,224,3 -> 112,112,16
    x = conv_block(inputs, 16, (3, 3), strides=(2, 2), nl='HS')
    x = bottleneck(x, 16, (3, 3), up_dim=16, stride=1, sq=False, nl='RE')
    # 112,112,16 -> 56,56,24
    x = bottleneck(x, 24, (3, 3), up_dim=64, stride=2, sq=False, nl='RE')
    x = bottleneck(x, 24, (3, 3), up_dim=72, stride=1, sq=False, nl='RE')
    # 56,56,24 -> 28,28,40
    x = bottleneck(x, 40, (5, 5), up_dim=72, stride=2, sq=True, nl='RE')
    x = bottleneck(x, 40, (5, 5), up_dim=120, stride=1, sq=True, nl='RE')
    x = bottleneck(x, 40, (5, 5), up_dim=120, stride=1, sq=True, nl='RE')
    # 28,28,40 -> 14,14,80
    x = bottleneck(x, 80, (3, 3), up_dim=240, stride=2, sq=False, nl='HS')
    x = bottleneck(x, 80, (3, 3), up_dim=200, stride=1, sq=False, nl='HS')
    x = bottleneck(x, 80, (3, 3), up_dim=184, stride=1, sq=False, nl='HS')
    x = bottleneck(x, 80, (3, 3), up_dim=184, stride=1, sq=False, nl='HS')
    # 14,14,80 -> 14,14,112
    x = bottleneck(x, 112, (3, 3), up_dim=480, stride=1, sq=True, nl='HS')
    x = bottleneck(x, 112, (3, 3), up_dim=672, stride=1, sq=True, nl='HS')
    # 14,14,112 -> 7,7,160
    x = bottleneck(x, 160, (5, 5), up_dim=672, stride=2, sq=True, nl='HS')
    x = bottleneck(x, 160, (5, 5), up_dim=960, stride=1, sq=True, nl='HS')
    x = bottleneck(x, 160, (5, 5), up_dim=960, stride=1, sq=True, nl='HS')
    # 7,7,160 -> 7,7,960
    x = conv_block(x, 960, (1, 1), strides=(1, 1), nl='HS')
    x = GlobalAveragePooling2D()(x)
    x = Reshape((1, 1, 960))(x)
    x = Conv2D(1280, (1, 1), padding='same')(x)
    x = return_activation(x, 'HS')
    x = Conv2D(n_class, (1, 1), padding='same', activation='softmax')(x)
    x = Reshape((n_class,))(x)
    model = Model(inputs, x)
    return model
if __name__ == "__main__":
    model = MobileNetv3_large()
    model.summary()

以上就是python神經(jīng)網(wǎng)絡(luò)MobileNetV3 large模型的復(fù)現(xiàn)詳解的詳細(xì)內(nèi)容,更多關(guān)于MobileNetV3 large模型復(fù)現(xiàn)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 顯卡驅(qū)動(dòng)CUDA?和?pytorch?CUDA?之間的區(qū)別

    顯卡驅(qū)動(dòng)CUDA?和?pytorch?CUDA?之間的區(qū)別

    本文主要介紹了顯卡驅(qū)動(dòng)CUDA?和?pytorch?CUDA?之間的區(qū)別,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-03-03
  • Python中的迭代器你了解嗎

    Python中的迭代器你了解嗎

    迭代器是一種特殊的對(duì)象,它實(shí)現(xiàn)了迭代協(xié)議,允許按照一定的順序逐個(gè)訪問元素,本文就來帶大家深入了解一下Python中迭代器的使用,需要的可以參考下
    2023-05-05
  • Python 爬取淘寶商品信息欄目的實(shí)現(xiàn)

    Python 爬取淘寶商品信息欄目的實(shí)現(xiàn)

    這篇文章主要介紹了Python 爬取淘寶商品信息欄目的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • python中tkinter復(fù)選框使用操作

    python中tkinter復(fù)選框使用操作

    Python Tkinter 復(fù)選框用來選取我們需要的選項(xiàng),它前面有個(gè)小正方形的方塊,如果選中則有一個(gè)對(duì)號(hào),也可以再次點(diǎn)擊以取消該對(duì)號(hào)來取消選中,下面通過代碼介紹下python中tkinter復(fù)選框使用操作,需要的朋友參考下吧
    2021-11-11
  • Python實(shí)現(xiàn)SQL注入檢測(cè)插件實(shí)例代碼

    Python實(shí)現(xiàn)SQL注入檢測(cè)插件實(shí)例代碼

    這篇文章主要給大家介紹了關(guān)于Python實(shí)現(xiàn)SQL注入檢測(cè)插件的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-02-02
  • PyQt5實(shí)現(xiàn)簡(jiǎn)單的計(jì)算器

    PyQt5實(shí)現(xiàn)簡(jiǎn)單的計(jì)算器

    這篇文章主要為大家詳細(xì)介紹了PyQt5實(shí)現(xiàn)簡(jiǎn)單的計(jì)算器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-05-05
  • Python用for循環(huán)實(shí)現(xiàn)九九乘法表

    Python用for循環(huán)實(shí)現(xiàn)九九乘法表

    本文通過實(shí)例代碼給大家介紹了Python用for循環(huán)實(shí)現(xiàn)九九乘法表的方法,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2018-05-05
  • 解決pycharm的Python console不能調(diào)試當(dāng)前程序的問題

    解決pycharm的Python console不能調(diào)試當(dāng)前程序的問題

    今天小編就為大家分享一篇解決pycharm的Python console不能調(diào)試當(dāng)前程序的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-01-01
  • 淺談dataframe中更改列屬性的方法

    淺談dataframe中更改列屬性的方法

    今天小編就為大家分享一篇淺談dataframe中更改列屬性的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-07-07
  • tensorflow之自定義神經(jīng)網(wǎng)絡(luò)層實(shí)例

    tensorflow之自定義神經(jīng)網(wǎng)絡(luò)層實(shí)例

    今天小編就為大家分享一篇tensorflow之自定義神經(jīng)網(wǎng)絡(luò)層實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-02-02

最新評(píng)論

高雄市| 邵阳市| 海安县| 唐河县| 蒙山县| 赤水市| 汶川县| 新龙县| 宜昌市| 汪清县| 花莲市| 黄梅县| 安远县| 孟连| 临桂县| 平和县| 都安| 江陵县| 洱源县| 青田县| 威信县| 惠东县| 福海县| 城口县| 阳信县| 奈曼旗| 邵阳市| 凤山市| 桐乡市| 罗江县| 元阳县| 通渭县| 手游| 巩义市| 九龙县| 彩票| 嫩江县| 枝江市| 萨迦县| 青神县| 辰溪县|