I'm doing a vector regression problem and many of the target vectors have a few components which are missing (so these components are recorded as nans in the training dataset). I think an elegant way to handle this would be to simply omit the terms in our objective function which correspond to these missing target values.

To be more specific, suppose the target vectors are $y_1, \ldots, y_N \in \mathbb R^K$, and let $\hat y_i \in \mathbb R^K$ be my prediction for the value of $y_i$. Typically I would train my model by minimizing the objective function value $$ L = \frac{1}{N} \sum_{i=1}^N \| y_i - \hat y_i \|_2^2. $$ However, to handle the missing target values in my training dataset, I would like to instead minimize the cost function $$ \tilde L = \frac{1}{N} \sum_{i=1}^N \sum_{k \in S_i} (y_{ik} - \hat y_{ik})^2 $$ where $y_{ik}$ is the $k$th component of the vector $y_i$, and the set $S_i \subset \{1, 2, \ldots, K\}$ tells us which components of $y_i$ which are not nan values.

Question: Does Keras provide an easy way (or a not-so-easy way) to use the modified objective function $\tilde L$ when I'm training my neural network?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.