code
stringlengths
3
6.57k
squeeze(-1)
squeeze(-1)
Yolact(nn.Module)
Parameters (in cfg.backbone)
len(selected_layers)
scales (see PredictionModule)
len(selected_layers)
__init__(self, only_last_layer=False)
super()
__init__()
construct_backbone(cfg.backbone)
self.freeze_bn()
torch.Tensor(np.load(cfg.mask_proto_grid_file)
self.grid.size(0)
make_net(in_channels, cfg.mask_proto_net, include_last_relu=False)
FastMaskIoUNet()
FPN([src_channels[i] for i in self.selected_layers])
list(range(len(self.selected_layers)
len(self.selected_layers)
nn.ModuleList()
len(self.selected_layers)
enumerate(self.selected_layers)
self.prediction_layers.append(pred)
nn.Linear(src_channels[-1], cfg.num_classes - 1)
nn.Conv2d(src_channels[0], cfg.num_classes-1, kernel_size=1)
save_weights(self, path)
torch.save(self.state_dict()
load_weights(self, path)
torch.load(path)
these (the new variable is called layers)
list(state_dict.keys()
key.startswith('backbone.layer')
key.startswith('backbone.layers')
key.startswith('fpn.downsample_layers.')
int(key.split('.')
self.load_state_dict(state_dict)
self.load_state_dict(state_dict)
print('Ignoring "' + str(e)
init_weights(self, backbone_path)
self.backbone.init_backbone(backbone_path)
getattr(nn.Conv2d(1, 1, 1)
all_in(x, y)
self.named_modules()
type(module)
hasattr(module, 'original_name')
all_in(module.__dict__['_constants_set'], conv_constants)
all_in(conv_constants, module.__dict__['_constants_set'])
isinstance(module, nn.Conv2d)
nn.init.xavier_uniform_(module.weight.data)
sum(exp(x)
exp(x_0)
log(z * (1 - pi)
log(z / c)
simplicity (and because we have a degree of freedom here)
log((1 - pi)
log(c)
np.log((1 - cfg.focal_loss_init_pi)
np.log(module.bias.size(0)
np.log(cfg.focal_loss_init_pi / (1 - cfg.focal_loss_init_pi)
np.log((1 - cfg.focal_loss_init_pi)
module.bias.data.zero_()
train(self, mode=True)
super()
train(mode)
self.freeze_bn()
freeze_bn(self, enable=False)
self.modules()
isinstance(module, nn.BatchNorm2d)
module.train()
module.eval()
forward(self, x)
x.size()
timer.env('backbone')
self.backbone(x)
timer.env('fpn')
self.fpn(outs)
timer.env('proto')
self.grid.repeat(proto_x.size(0)
torch.cat([proto_x, grids], dim=1)
self.proto_net(proto_x)
cfg.mask_proto_prototype_activation(proto_out)
proto_out.clone()
proto_out.detach()
proto_out.permute(0, 2, 3, 1)
contiguous()
proto_out.size()
torch.cat([proto_out, torch.ones(*bias_shape)
timer.env('pred_heads')
zip(self.selected_layers, self.prediction_layers)
F.interpolate(proto_downsampled, size=outs[idx].size()
torch.cat([pred_x, proto_downsampled], dim=1)
pred_layer(pred_x.detach()
pred_layer(pred_x)
p.items()
append(v)
pred_outs.items()
torch.cat(v, -2)
self.class_existence_fc(outs[-1].mean(dim=(2, 3)
self.semantic_seg_conv(outs[0])
torch.sigmoid(pred_outs['score'])