我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用chainer.links.Inception()。
def __init__(self): super(GoogLeNet, self).__init__( conv1=L.Convolution2D(3, 64, 7, stride=2, pad=3), conv2_reduce=L.Convolution2D(64, 64, 1), conv2=L.Convolution2D(64, 192, 3, stride=1, pad=1), inc3a=L.Inception(192, 64, 96, 128, 16, 32, 32), inc3b=L.Inception(256, 128, 128, 192, 32, 96, 64), inc4a=L.Inception(480, 192, 96, 208, 16, 48, 64), inc4b=L.Inception(512, 160, 112, 224, 24, 64, 64), inc4c=L.Inception(512, 128, 128, 256, 24, 64, 64), inc4d=L.Inception(512, 112, 144, 288, 32, 64, 64), inc4e=L.Inception(528, 256, 160, 320, 32, 128, 128), inc5a=L.Inception(832, 256, 160, 320, 32, 128, 128), inc5b=L.Inception(832, 384, 192, 384, 48, 128, 128), loss3_fc=L.Linear(1024, 1000), loss1_conv=L.Convolution2D(512, 128, 1), loss1_fc1=L.Linear(4 * 4 * 128, 1024), loss1_fc2=L.Linear(1024, 1000), loss2_conv=L.Convolution2D(528, 128, 1), loss2_fc1=L.Linear(4 * 4 * 128, 1024), loss2_fc2=L.Linear(1024, 1000) ) self.train = True
def __init__(self): super(GoogLeNet, self).__init__() with self.init_scope(): self.conv1 = L.Convolution2D(None, 64, 7, stride=2, pad=3) self.conv2_reduce = L.Convolution2D(None, 64, 1) self.conv2 = L.Convolution2D(None, 192, 3, stride=1, pad=1) self.inc3a = L.Inception(None, 64, 96, 128, 16, 32, 32) self.inc3b = L.Inception(None, 128, 128, 192, 32, 96, 64) self.inc4a = L.Inception(None, 192, 96, 208, 16, 48, 64) self.inc4b = L.Inception(None, 160, 112, 224, 24, 64, 64) self.inc4c = L.Inception(None, 128, 128, 256, 24, 64, 64) self.inc4d = L.Inception(None, 112, 144, 288, 32, 64, 64) self.inc4e = L.Inception(None, 256, 160, 320, 32, 128, 128) self.inc5a = L.Inception(None, 256, 160, 320, 32, 128, 128) self.inc5b = L.Inception(None, 384, 192, 384, 48, 128, 128) self.loss3_fc = L.Linear(None, 1000) self.loss1_conv = L.Convolution2D(None, 128, 1) self.loss1_fc1 = L.Linear(None, 1024) self.loss1_fc2 = L.Linear(None, 1000) self.loss2_conv = L.Convolution2D(None, 128, 1) self.loss2_fc1 = L.Linear(None, 1024) self.loss2_fc2 = L.Linear(None, 1000)
def __init__(self): super(GoogLeNet, self).__init__( conv1=L.Convolution2D(None, 64, 7, stride=2, pad=3), conv2_reduce=L.Convolution2D(None, 64, 1), conv2=L.Convolution2D(None, 192, 3, stride=1, pad=1), inc3a=L.Inception(None, 64, 96, 128, 16, 32, 32), inc3b=L.Inception(None, 128, 128, 192, 32, 96, 64), inc4a=L.Inception(None, 192, 96, 208, 16, 48, 64), inc4b=L.Inception(None, 160, 112, 224, 24, 64, 64), inc4c=L.Inception(None, 128, 128, 256, 24, 64, 64), inc4d=L.Inception(None, 112, 144, 288, 32, 64, 64), inc4e=L.Inception(None, 256, 160, 320, 32, 128, 128), inc5a=L.Inception(None, 256, 160, 320, 32, 128, 128), inc5b=L.Inception(None, 384, 192, 384, 48, 128, 128), loss3_fc=L.Linear(None, 1000), loss1_conv=L.Convolution2D(None, 128, 1), loss1_fc1=L.Linear(None, 1024), loss1_fc2=L.Linear(None, 1000), loss2_conv=L.Convolution2D(None, 128, 1), loss2_fc1=L.Linear(None, 1024), loss2_fc2=L.Linear(None, 1000) ) self.train = True
def __init__(self): super(GoogleNet, self).__init__() with self.init_scope(): self.conv1=L.Convolution2D(None, 64, 7, stride=2, pad=3) self.conv2_reduce=L.Convolution2D(None, 64, 1) self.conv2=L.Convolution2D(None, 192, 3, stride=1, pad=1) self.inc3a=L.Inception(None, 64, 96, 128, 16, 32, 32) self.inc3b=L.Inception(None, 128, 128, 192, 32, 96, 64) self.inc4a=L.Inception(None, 192, 96, 208, 16, 48, 64) self.inc4b=L.Inception(None, 160, 112, 224, 24, 64, 64) self.inc4c=L.Inception(None, 128, 128, 256, 24, 64, 64) self.inc4d = L.Inception(None, 112, 144, 288, 32, 64, 64) self.inc4e = L.Inception(None, 256, 160, 320, 32, 128, 128) self.inc5a = L.Inception(None, 256, 160, 320, 32, 128, 128) self.inc5b = L.Inception(None, 384, 192, 384, 48, 128, 128) self.loss3_fc = L.Linear(None, 1000) self.loss1_conv = L.Convolution2D(None, 128, 1) self.loss1_fc1 = L.Linear(None, 1024) self.loss1_fc2 = L.Linear(None, 1000) self.loss2_conv = L.Convolution2D(None, 128, 1) self.loss2_fc1 = L.Linear(None, 1024) self.loss2_fc2 = L.Linear(None, 1000)
def setUp(self): self.x = numpy.random.uniform( -1, 1, (10, self.in_channels, 5, 5) ).astype(numpy.float32) out = self.out1 + self.out3 + self.out5 + self.proj_pool self.gy = numpy.random.uniform( -1, 1, (10, out, 5, 5)).astype(numpy.float32) self.l = links.Inception( self.in_channels, self.out1, self.proj3, self.out3, self.proj5, self.out5, self.proj_pool)