本文整理汇总了Python中torch.nn.functional.max_pool2d函数的典型用法代码示例。如果您正苦于以下问题:Python max_pool2d函数的具体用法?Python max_pool2d怎么用?Python max_pool2d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了max_pool2d函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: forward
def forward(self, x):
x = self.conv1(x)
x = F.max_pool2d(x, 2) + F.avg_pool2d(x, 2)
x = self.block1(x)
x = self.group1(x)
x = F.max_pool2d(x, 2) + F.avg_pool2d(x, 2)
x = self.block2(x)
x = self.group2(x)
x = F.max_pool2d(x, 2) + F.avg_pool2d(x, 2)
x = self.block3(x)
x = self.group3(x)
x = self.block4(x)
x = self.group4(x)
x = F.max_pool2d(x, 2) + F.avg_pool2d(x, 2)
x = x.view(x.size(0), -1)
fc = self.fc(x)
x = F.dropout(fc, training=self.training)
output = list()
for name, fun in self.fc_dict.iteritems():
out = fun(x)
output.append(out)
return output, fc
开发者ID:m-bain,项目名称:pytorch-multi-label-classifier,代码行数:28,代码来源:lightcnn.py
示例2: forward
def forward(self, X):
h = F.relu(self.conv1_1(X), inplace=True)
h = F.relu(self.conv1_2(h), inplace=True)
# relu1_2 = h
h = F.max_pool2d(h, kernel_size=2, stride=2)
h = F.relu(self.conv2_1(h), inplace=True)
h = F.relu(self.conv2_2(h), inplace=True)
# relu2_2 = h
h = F.max_pool2d(h, kernel_size=2, stride=2)
h = F.relu(self.conv3_1(h), inplace=True)
h = F.relu(self.conv3_2(h), inplace=True)
h = F.relu(self.conv3_3(h), inplace=True)
# relu3_3 = h
h = F.max_pool2d(h, kernel_size=2, stride=2)
h = F.relu(self.conv4_1(h), inplace=True)
h = F.relu(self.conv4_2(h), inplace=True)
h = F.relu(self.conv4_3(h), inplace=True)
# relu4_3 = h
h = F.relu(self.conv5_1(h), inplace=True)
h = F.relu(self.conv5_2(h), inplace=True)
h = F.relu(self.conv5_3(h), inplace=True)
relu5_3 = h
return relu5_3
开发者ID:phonx,项目名称:MUNIT,代码行数:28,代码来源:networks.py
示例3: forward
def forward(self, x):
x = F.max_pool2d(F.relu(self.conv1(x)), 2)
x = F.max_pool2d(F.relu(self.conv2(x)), 2)
x = x.view(-1, 64 * 7 * 7) # reshape Variable
x = F.relu(self.fc1(x))
x = self.fc2(x)
return F.log_softmax(x, dim=-1)
开发者ID:limin24kobe,项目名称:cleverhans,代码行数:7,代码来源:mnist_tutorial_pytorch.py
示例4: forward
def forward(self, x):
x = F.relu(F.max_pool2d(self.conv1(x), 2))
x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2))
x = x.view(-1, 320)
x = F.relu(self.fc1(x))
x = F.dropout(x, training=self.training)
return F.log_softmax(self.fc2(x))
开发者ID:nikcheerla,项目名称:mitosis-detection,代码行数:7,代码来源:pytorch_cnn.py
示例5: forward
def forward(self, x):
out = F.relu(F.max_pool2d(self.conv1(x), 2))
out = F.relu(F.max_pool2d(self.conv2(out), 2))
out = out.view(-1, 320)
out = F.relu(self.fc1(out))
out = self.fc2(out)
return F.log_softmax(out, dim=1)
开发者ID:kevinzakka,项目名称:blog-code,代码行数:7,代码来源:classic.py
示例6: forward
def forward(self, x):
x = F.relu(F.max_pool2d(self.conv1(x), 2))
x = F.relu(F.max_pool2d(self.conv2(x), 2))
x = x.view(-1, 320)
x = F.relu(self.fc1(x))
x = self.fc2(x)
return x
开发者ID:lewisKit,项目名称:pyro,代码行数:7,代码来源:sv-dkl.py
示例7: forward
def forward(self, x):
if self.transform_input:
x = x.clone()
x[:, 0] = x[:, 0] * (0.229 / 0.5) + (0.485 - 0.5) / 0.5
x[:, 1] = x[:, 1] * (0.224 / 0.5) + (0.456 - 0.5) / 0.5
x[:, 2] = x[:, 2] * (0.225 / 0.5) + (0.406 - 0.5) / 0.5
else: warn("Input isn't transformed")
x = self.Conv2d_1a_3x3(x)
x = self.Conv2d_2a_3x3(x)
x = self.Conv2d_2b_3x3(x)
x = F.max_pool2d(x, kernel_size=3, stride=2)
x = self.Conv2d_3b_1x1(x)
x = self.Conv2d_4a_3x3(x)
x = F.max_pool2d(x, kernel_size=3, stride=2)
x = self.Mixed_5b(x)
x = self.Mixed_5c(x)
x = self.Mixed_5d(x)
x = self.Mixed_6a(x)
x = self.Mixed_6b(x)
x = self.Mixed_6c(x)
x = self.Mixed_6d(x)
x = self.Mixed_6e(x)
x = self.Mixed_7a(x)
x = self.Mixed_7b(x)
x_for_attn = x = self.Mixed_7c(x)
# 8 x 8 x 2048
x = F.avg_pool2d(x, kernel_size=8)
# 1 x 1 x 2048
x_for_capt = x = x.view(x.size(0), -1)
# 2048
x = self.fc(x)
# 1000 (num_classes)
return x_for_attn, x_for_capt, x
开发者ID:mdasadul,项目名称:Practical_DL,代码行数:33,代码来源:beheaded_inception3.py
示例8: forward
def forward(self, x):
x1 = self.conv1(x)
x1 = F.max_pool2d(x1, 3, stride=2)
x2 = self.fire2(x1)
x3 = self.fire3(x2)
if self.bypass:
x3 = x3 + x2
x4 = self.fire4(x3)
x4 = F.max_pool2d(x4, 3, stride=2)
x5 = self.fire5(x4)
if self.bypass:
x5 = x5 + x4
x6 = self.fire6(x5)
x7 = self.fire7(x6)
if self.bypass:
x7 = x7 + x6
x8 = self.fire8(x7)
x8 = F.max_pool2d(x8, 3, stride=2)
x9 = self.fire9(x8)
if self.bypass:
x9 = x9 + x8
x9 = F.dropout(x9, training=self.training)
x10 = F.relu(self.conv10(x9))
f = F.avg_pool2d(x10, x10.size()[2:]).view(x10.size(0), -1)
if not self.training:
return f
if self.loss == {'xent'}:
return f
elif self.loss == {'xent', 'htri'}:
return f, f
else:
raise KeyError("Unsupported loss: {}".format(self.loss))
开发者ID:zysolanine,项目名称:deep-person-reid,代码行数:34,代码来源:squeeze.py
示例9: forward
def forward(self, x):
x = F.relu(F.max_pool2d(self.conv1(x), 2))
x = F.relu(F.max_pool2d(self.conv2(x), 2))
x = x.view(-1, 7*7*64)
x = F.relu(self.fc1(x))
x = F.dropout(x, 0.4)
x = self.fc2(x)
return F.log_softmax(x, dim=1)
开发者ID:danielhers,项目名称:cnn,代码行数:8,代码来源:mnist_pytorch.py
示例10: forward
def forward(self, x):
x = F.relu(F.max_pool2d(self.conv1(x), 2))
x = F.relu(F.max_pool2d(self.conv2(x), 2))
x = x.view(-1, 1600)
x = F.relu(self.fc1(x))
x = F.dropout(x, training=self.training)
x = self.fc2(x)
return th.abs(10 - x)
开发者ID:BrianDo2005,项目名称:torchsample,代码行数:8,代码来源:single_input_no_target.py
示例11: forward
def forward(self, x):
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2)) # max pooling over a 2x2 window
x = F.max_pool2d(F.relu(self.conv2(x)), 2) # square x can only specify single number
x = x.view(-1, self.num_flat_features(x))
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
开发者ID:deo1,项目名称:deo1,代码行数:8,代码来源:tutorial.py
示例12: deepcompare_2ch
def deepcompare_2ch(input, params):
o = conv2d(input, params, 'conv0', stride=3)
o = F.max_pool2d(F.relu(o), 2, 2)
o = conv2d(o, params, 'conv1')
o = F.max_pool2d(F.relu(o), 2, 2)
o = conv2d(o, params, 'conv2')
o = F.relu(o).view(o.size(0), -1)
return linear(o, params, 'fc')
开发者ID:szagoruyko,项目名称:cvpr15deepcompare,代码行数:8,代码来源:eval.py
示例13: forward
def forward(self, x):
x = F.max_pool2d(F.relu(self.convolution_0(x)), (2, 2))
x = F.max_pool2d(F.relu(self.convolution_1(x)), (2, 2))
x = x.view(-1, 32 * 5 * 5)
x = F.relu(self.fully_connected_0(x))
x = F.relu(self.fully_connected_1(x))
x = self.fully_connected_2(x)
return x
开发者ID:mraxilus,项目名称:experiments,代码行数:8,代码来源:create_neural_network.py
示例14: forward
def forward(self, x):
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2)) # Max pooling over a (2, 2) window
x = F.max_pool2d(F.relu(self.conv2(x)), 2) # If the size is a square you can only specify a single number
x = x.view(-1, self.num_flat_features(x))
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
开发者ID:Suluo,项目名称:Kaggle,代码行数:8,代码来源:test.py
示例15: forward
def forward(self, x, y, z):
x = F.relu(F.max_pool2d(self.conv1(x), 2))
x = F.relu(F.max_pool2d(self.conv2(x), 2))
x = x.view(-1, 1600)
x = F.relu(self.fc1(x))
x = F.dropout(x, training=self.training)
x = self.fc2(x)
return F.log_softmax(x), F.log_softmax(x), F.log_softmax(x)
开发者ID:BrianDo2005,项目名称:torchsample,代码行数:8,代码来源:multi_input_multi_target.py
示例16: siam
def siam(patch, params):
o = conv2d(patch, params, 'conv0', stride=3)
o = F.max_pool2d(F.relu(o), 2, 2)
o = conv2d(o, params, 'conv1')
o = F.max_pool2d(F.relu(o), 2, 2)
o = conv2d(o, params, 'conv2')
o = F.relu(o)
return o.view(o.size(0), -1)
开发者ID:szagoruyko,项目名称:cvpr15deepcompare,代码行数:8,代码来源:eval.py
示例17: forward
def forward(self, x):
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))
x = F.max_pool2d(F.relu(self.conv2(x)), 2)
x = x.view(-1, self.num_flat_features(x))
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
开发者ID:terasakisatoshi,项目名称:PythonCode,代码行数:8,代码来源:network.py
示例18: forward
def forward(self, x):
steps=x.shape[0]
batch=x.shape[1]
x=x.view(x.shape[0]*x.shape[1],1,-1,11)
out = F.max_pool2d(self.conv1(x), (2, 1))
out = F.max_pool2d(self.conv2(out), (2, 2))
out= out.view(steps,batch,-1)
return out
开发者ID:yunzqq,项目名称:pytorch-kaldi,代码行数:8,代码来源:neural_nets.py
示例19: forward
def forward(self,x):
x = F.max_pool2d(F.relu(self.conv1(x)),(2,2))
x = F.max_pool2d(F.relu(self.conv2(x)),2)
x = x.view(x.size()[0],-1)
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
开发者ID:ZhangXinNan,项目名称:LearnPractice,代码行数:8,代码来源:cifar10.py
示例20: forward
def forward(self, x):
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))
x = F.max_pool2d(F.relu(self.conv2(x)), 2) # when shape is square, a single number is fine.
x = x.view(-1, self.num_flat_features(x))
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
开发者ID:episodeyang,项目名称:deep_learning_notes,代码行数:8,代码来源:torch_sample_cnn.py
注:本文中的torch.nn.functional.max_pool2d函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论