I am trying to do something similar to Instance Mapping projection, where I project the instance segmentation results (output from sigmoid function) to a softmax probability map. However, I get error saying that the gradient computation has been modified by an inplace operation. How do I solve this ? any suggestions.
Here is the code
feature_probs = F.softmax(feature_probs,1) [ 1xCxHxW] masks = masks_logits.sigmoid() [Nx1x28x28] boxes = [Nx4] classes = [Nx1] for mask, box, pred_class in zip(masks, boxes, classes): w = box - box h = box - box resize_mask = interpolate(mask, [w,h]) feature_prob[pred_class+1: box:box,box:box ] = resize_mask feature_prob_normalize = F.normalize(feature_prob, p=1 ,dim=0) loss = calculate_loss(feature_prob_normalize, target)
Error : RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 7, 256, 256]], which is output 0 of SoftmaxBackward. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later.