how to do Grid and Rondom proposal boxes initialization?
Thanks for your code. Can you provide the code of Grid and Random initialization method? For example, the specific mean and std paramter of the Gaussian distribution. Thank you very much.
self.init_proposal_boxes = nn.Embedding(self.num_proposals, 4)
if self.init_type == "img":
nn.init.constant_(self.init_proposals.weight[:, :2], 0.5)
nn.init.constant_(self.init_proposals.weight[:, 2:], 1.0)
elif self.init_type == "center":
nn.init.constant_(self.init_proposals.weight[:, :2], 0.5)
nn.init.constant_(self.init_proposals.weight[:, 2:], 0.1)
elif self.init_type == "grid":
scale = math.sqrt(1. / self.num_queries)
steps = int(math.sqrt(self.num_queries)) + 1
x_range = torch.linspace(0., 1., steps)[:-1] + scale / 2
y_range = torch.linspace(0., 1., steps)[:-1] + scale / 2
y_range, x_range = torch.meshgrid(y_range, x_range)
centers = torch.cat([x_range.reshape(-1, 1), y_range.reshape(-1, 1)], 1)
nn.init.constant_(self.init_proposals.weight[:, 2:], scale)
for i in range(self.num_queries):
nn.init.constant_(self.init_proposals.weight[i, 0], centers[i, 0])
nn.init.constant_(self.init_proposals.weight[i, 1], centers[i, 1])
elif self.init_type == "random":
pass
@liz6688 If you find any bug when using different initializations, please remind me, thanks~
Got it. Thanks.
Hi! Thanks for the code.
When I used the "Random" initialization to do the training, the program reported error "assert (boxes[:, 2:] >= boxes1[:, :2]).all()" for the "generalized_box_iou" function in util/box_ops.py. I suppose the error comes from the situation that the box at some time gets a negative width or height. May I know if the "Random" intialization is responsible for this phenomenon? How could we do the "Random" initialization safety and avoid this problem? Are there any extra constraints needed?
Thank you in advance.
How could we do the "Random" initialization safety and avoid this problem? Are there any extra constraints needed?
I followed the way in the above code to random initialize proposal boxes with mmdetection but the loss became very big and cannot train. Have you solved the "Random" initialization problem? :)