PyTorch之nn.ReLU与F.ReLU的区别是什么-创新互联

创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

创新互联自2013年创立以来,先为禹州等服务建站,禹州等地企业,进行企业商务咨询服务。为禹州企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

这篇文章将为大家详细讲解有关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的区别是什么-创新互联
网站URL:http://scyanting.com/article/cdgdos.html