1

I have so many Nan values in my output data and I padded those values with zeros. Please don't suggest me to delete Nan or impute with any other no. I want model to skip those nan positions.

example:

x = np.arange(0.5, 30)
x.shape = [10, 3]

x = [[ 0.5  1.5  2.5]
 [ 3.5  4.5  5.5]
 [ 6.5  7.5  8.5]
 [ 9.5 10.5 11.5]
 [12.5 13.5 14.5]
 [15.5 16.5 17.5]
 [18.5 19.5 20.5]
 [21.5 22.5 23.5]
 [24.5 25.5 26.5]
 [27.5 28.5 29.5]]

y = np.arange(2, 10, 0.8)

y.shape = [10, 1] 

y[4, 0] = 0.0

y[6, 0] = 0.0

y[7, 0] = 0.0

y = [[2. ]
[2.8]
[3.6]
[4.4]
[0. ]
[6. ]
[0. ]
[0. ]
[8.4]
[9.2]]

I expect keras deep learning model to predict zeros for 5th, 7th and 8th row as similar to the padded value in 'y'.

1
  • Use this sample code to mask labels tensor = [0, 1, 2, 3] mask = np.array([True, False, True, False]) tf.boolean_mask(tensor, mask). Thanks! Commented Jun 15, 2021 at 3:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.