when I try to run the following code:
def pixel_drop(image, drop_rate=0.5):
img_h, img_w, _ = image.shape
pixel_count = img_h * img_w
drop_num = pixel_count * drop_rate
for drop in range(int(drop_num)):
rand_x = random.randint(0, img_h - 1)
rand_y = random.randint(0, img_w - 1)
image[rand_x, rand_y,:] = 0
return image
I seem to get the following error:
TypeError: 'Tensor' object does not support item assignment
It looks like I can't assign things to a tensor. How should I go about implementing this?
image[rand_x, rand_y,:] = 0the cause of the error ? Which line ?