I wonder if somebody knows how to implement my problem in a more efficient way.
Problem statement: use index_tensor to fill regions in target_tensor with zeros
- target_tensor of shape [2, 540, 40, 40, 64] (batch size 2, channels 540, 3D image)
- index_tensor of shape [2, 540, 6] (batch size 2, channels 540, coordinates in the 3D image in the format x1, y1, z1, x2, y2, z2)
Right now I am solving this task with 2 for-loops which is not optimal:
for b in range(batch_size):
for q in range(channels):
target_tensor[b, q, index_tensor[b, q, 0]:index_tensor[b, q, 3], index_tensor[b, q, 1]:index_tensor[b, q, 4], index_tensor[b, q, 2]:index_tensor[b, q, 5]] = 0
I would be grateful for any hints, as this would significantly speed up my training process.
BR