056338255ea968d28ab462295b308cf475adcdde,chainer_/models/dpn.py,DPN,__init__,#DPN#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#,358
Before Change
self.features.add(stage)
self.features.add(DPNFinalBlock(channels=in_channels))
self.output = nn.HybridSequential(prefix="")
if for_training or not test_time_pool:
self.output.add(nn.GlobalAvgPool2D())
self.output.add(conv1x1(
in_channels=in_channels,
out_channels=classes,
use_bias=True))
self.output.add(nn.Flatten())
else:
self.output.add(nn.AvgPool2D(
pool_size=7,
strides=1))
self.output.add(conv1x1(
in_channels=in_channels,
out_channels=classes,
use_bias=True))
self.output.add(GlobalAvgMaxPool2D())
self.output.add(nn.Flatten())
def hybrid_forward(self, F, x):
x = self.features(x)
x = self.output(x)
After Change
setattr(self.features, "stage{}".format(i + 1), stage)
setattr(self.features, "final_block", DPNFinalBlock(channels=in_channels))
self.output = SimpleSequential()
with self.output.init_scope():
if for_training or not test_time_pool:
setattr(self.output, "final_pool", GlobalAvgPool2D())
setattr(self.output, "final_conv", conv1x1(
in_channels=in_channels,
out_channels=classes,
use_bias=True))
setattr(self.output, "final_flatten", partial(
F.reshape,
shape=(-1, classes)))
else:
setattr(self.output, "avg_pool", partial(
F.average_pooling_2d,
ksize=7,
stride=1))
setattr(self.output, "final_conv", conv1x1(
in_channels=in_channels,
out_channels=classes,
use_bias=True))
setattr(self.output, "avgmax_pool", GlobalAvgMaxPool2D())
setattr(self.output, "final_flatten", partial(
F.reshape,
shape=(-1, classes)))
def __call__(self, x):
x = self.features(x)
x = self.output(x)
return x
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 24
Instances
Project Name: osmr/imgclsmob
Commit Name: 056338255ea968d28ab462295b308cf475adcdde
Time: 2018-09-05
Author: osemery@gmail.com
File Name: chainer_/models/dpn.py
Class Name: DPN
Method Name: __init__
Project Name: osmr/imgclsmob
Commit Name: 056338255ea968d28ab462295b308cf475adcdde
Time: 2018-09-05
Author: osemery@gmail.com
File Name: chainer_/models/dpn.py
Class Name: DPN
Method Name: __init__
Project Name: osmr/imgclsmob
Commit Name: 553f777ad245ef3caa799151e34e6cc37bbcb11a
Time: 2020-02-18
Author: osemery@gmail.com
File Name: gluon/gluoncv2/models/mobilenetv2.py
Class Name: MobileNetV2
Method Name: __init__
Project Name: osmr/imgclsmob
Commit Name: 29eac269527a4466dfef282374aed49ce66d9bfb
Time: 2018-09-06
Author: osemery@gmail.com
File Name: chainer_/models/nasnet.py
Class Name: NASNet
Method Name: __init__