PyTorch之nn.ReLU与F.ReLU的区别是什么-创新互联
创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

这篇文章将为大家详细讲解有关PyTorch之nn.ReLU与F.ReLU的区别是什么,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
我就废话不多说了,大家还是直接看代码吧~
import torch.nn as nn
import torch.nn.functional as F
import torch.nn as nn
class AlexNet_1(nn.Module):
def __init__(self, num_classes=n):
super(AlexNet, self).__init__()
self.features = nn.Sequential(
nn.Conv2d(3, 64, kernel_size=3, stride=2, padding=1),
nn.BatchNorm2d(64),
nn.ReLU(inplace=True),
)
def forward(self, x):
x = self.features(x)
class AlexNet_2(nn.Module):
def __init__(self, num_classes=n):
super(AlexNet, self).__init__()
self.features = nn.Sequential(
nn.Conv2d(3, 64, kernel_size=3, stride=2, padding=1),
nn.BatchNorm2d(64),
)
def forward(self, x):
x = self.features(x)
x = F.ReLU(x) 当前文章:PyTorch之nn.ReLU与F.ReLU的区别是什么-创新互联
文章地址:http://www.jxjierui.cn/article/cdgdos.html


咨询
建站咨询
