import numpy as np
import torch
from torch import nn
from torch.autograd import Variable
def conv_relu(in_channel, out_channel, kernel, stride=1, padding=0):
layer = nn.Sequential(
nn.Conv2d(in_channel, out_channel, kernel, stride, padding),
nn.BatchNorm2d(out_channel, eps=1e-3),
nn.ReLU(True)
)
return layer
class inception(nn.Module):
def __init__(self,in_channel,out1_1,out2_1,out2_3,out3_1,out3_5,out4_1):
super(inception,self).__init__()
#第一条路
self.branch1_1 = conv_relu(in_channel,out1_1,1)
#第二条路
self.branch3_3 = nn.Sequential(
conv_relu(in_channel, out2_1, 1),
conv_relu(out2_1, out2_3, 3, padding=1)
)
#第三条路
self.branch5_5 = nn.Sequential(
conv_relu(in_channel, out3_1, 1),
conv_relu(out3_1, out3_5, 5, padding=2)
)
#第四条路
self.branch_pool = nn.Sequential(
简单GoogLeNet实现
最新推荐文章于 2023-07-05 18:02:46 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)