title: How to train on single image depth estimation on KITTI dataset with masking method
body: <p>I'm studying on a deep learning(supervised-learning) to estimate depth images from monocular images.
  And the dataset currently uses KITTI data. RGB images (input image) are used KITTI Raw data, and data from the <a href="http://www.cvlibs.net/datasets/kitti/eval_depth.php?benchmark=depth_prediction" rel="nofollow noreferrer">following link</a> is used for ground-truth.</p>
  <p>In the process of learning a model by designing a simple encoder-decoder network, the result is not so good, so various attempts are being made.</p>
  <p>While searching for various methods, I found that groundtruth only learns valid areas by masking because there are many invalid areas, i.e., values that cannot be used, as shown in the image below.
  <a href="https://i.stack.imgur.com/wyCod.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wyCod.png" alt="enter image description here" /></a></p>
  <p>So, I learned through masking, but I am curious about why this result keeps coming out.</p>
  <p><a href="https://i.stack.imgur.com/I1LvA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I1LvA.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/jmfGo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jmfGo.png" alt="[training-result_2]--&gt;&gt;[5]" /></a></p>
  <p>and this is my training part of code.
  How can i fix this problem.</p>
  <pre><code>for epoch in range(num_epoch):
  model.train() ### train ###
  for batch_idx, samples in enumerate(tqdm(train_loader)):
      x_train = samples['RGB'].to(device)
      y_train = samples['groundtruth'].to(device)
  
      pred_depth = model.forward(x_train)
      valid_mask = y_train != 0     #### Here is masking 
  
      valid_gt_depth = y_train[valid_mask]
      valid_pred_depth = pred_depth[valid_mask]
  
      loss = loss_RMSE(valid_pred_depth, valid_gt_depth)
  </code></pre>