亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

pytorch方法測試——激活函數(shù)(ReLU)詳解

 更新時間:2020年01月15日 16:12:38   作者:tmk_01  
今天小編就為大家分享一篇pytorch方法測試——激活函數(shù)(ReLU)詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

測試代碼:

import torch
import torch.nn as nn

#inplace為True,將會改變輸入的數(shù)據(jù) ,否則不會改變原輸入,只會產(chǎn)生新的輸出
m = nn.ReLU(inplace=True)
input = torch.randn(7)

print("輸入處理前圖片:")
print(input)

output = m(input)

print("ReLU輸出:")
print(output)
print("輸出的尺度:")
print(output.size())

print("輸入處理后圖片:")
print(input)

輸出為:

輸入處理前圖片:

tensor([ 1.4940, 1.0278, -1.9883, -0.1871, 0.4612, 0.0297, 2.4300])

ReLU輸出:

tensor([ 1.4940, 1.0278, 0.0000, 0.0000, 0.4612, 0.0297, 2.4300])

輸出的尺度:

torch.Size([7])

輸入處理后圖片:

tensor([ 1.4940, 1.0278, 0.0000, 0.0000, 0.4612, 0.0297, 2.4300])

結(jié)論:

nn.ReLU(inplace=True)

inplace為True,將會改變輸入的數(shù)據(jù) ,否則不會改變原輸入,只會產(chǎn)生新的輸出

以上這篇pytorch方法測試——激活函數(shù)(ReLU)詳解就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論