RAMS icon indicating copy to clipboard operation
RAMS copied to clipboard

#issue help wanted 8 reference for mask matrix of 1s

Open bibuzz opened this issue 3 years ago • 2 comments

@fsalv @EscVM With reference to https://github.com/EscVM/RAMS/issues/8#issuecomment-867725589 Matrix of how many ones should I set cropped_y_mask as ?

cropped_y_mask = tf.cast([1,1,1,1,1], tf.float32)

    cropped_predictions_masked = tf.cast(
        cropped_predictions, tf.float32)*cropped_y_mask
    cropped_labels_masked = cropped_labels*cropped_y_mask

    total_pixels_masked = tf.reduce_sum(cropped_y_mask, axis=[1, 2])

I am getting error InvalidArgumentError: Invalid reduction dimension (1 for input with 1 dimension(s) [Op:Sum] D:\SuperResolution\RAMS\utils\loss.py in l1_loss(y_true, y_pred, HR_SIZE) 50 cropped_labels_masked = cropped_labels*cropped_y_mask 51 ---> 52 total_pixels_masked = tf.reduce_sum(cropped_y_mask, axis=[1, 2]) 53 54 # bias brightness

I tried all combos cropped_y_mask =[1,1,1,1,1] cropped_y_mask =[1] cropped_y_mask =[1,1]

FullError.txt Any help appreciated

bibuzz avatar Aug 02 '21 09:08 bibuzz

cropped_y_mask should have the same dimension of the output, so B x HR_SIZE x HR_SIZE x 1. All the combos you tried are one dimensional, so they won't work. Try using np.ones.

fsalv avatar Aug 10 '21 13:08 fsalv

Hi @fsalv @EscVM

I printed out the crop_prediction and the y_mask to see if dimensions same, and it does show the same now (48, 90, 90, 1), Like you said batch_sizehr_sizehr_size*1 (here my hr_size = 96, but some border pixel shift is done to make it 90 i guess I did try the other option as well (48, 96, 96, 1) and it resulted in same error)

cropped_y_mask = np.ones(shape=(48, 90, 90, 1), dtype=np.float32)

I have attached the loss.py and the complete error

Output ------ Epoch 1/100 crop predictions tf.Tensor( [[[[4612.5356 ] [3837.1716 ] [4633.922 ] ... [2775.706 ] [2106.822 ] [2689.7336 ]] ... [2897.199 ] [2584.3728 ] [2875.7666 ]]]], shape=(48, 90, 90, 1), dtype=float32)

crop y mask tf.Tensor( [[[[1.] [1.] [1.] ... [1.] [1.] [1.]] ... [1.]]]], shape=(48, 90, 90, 1), dtype=float32)

Error ------ D:\SuperResolution\RAMS\utils\loss.py in l1_loss(y_true, y_pred, HR_SIZE) 48 print("crop predictions",tf.cast(cropped_predictions, tf.float32)); 49 print("crop y mask", cropped_y_mask); ---> 50 cropped_predictions_masked = tf.cast( 51 cropped_predictions, tf.float32)cropped_y_mask 52 cropped_labels_masked = cropped_labelscropped_y_mask

InvalidArgumentError: required broadcastable shapes at loc(unknown) [Op:Mul] loss1.txt outputwitherror.txt

bibuzz avatar Aug 12 '21 04:08 bibuzz