Esempio n. 1
0
def pcl_loss(pclA, tMatP, tMatT, **kwargs):  # batchSize=Sne
    """
    Generate a ground truth point cloud using ground truth transformation
    Generate a prediction point cloud using predicted transformation
    L2 difference between ground truth and predicted point cloud is the loss value
    """
    # pclA, tMatP, tMatT are in batches
    # tMatP, tMatT should get a 0,0,0,1 row and be reshaped to 4x4
    tMatP = tf.concat([
        tMatP,
        tf.constant(
            np.repeat(np.array([[0, 0, 0, 1]], dtype=np.float32),
                      kwargs.get('activeBatchSize'),
                      axis=0))
    ], 1)
    tMatT = tf.concat([
        tMatT,
        tf.constant(
            np.repeat(np.array([[0, 0, 0, 1]], dtype=np.float32),
                      kwargs.get('activeBatchSize'),
                      axis=0))
    ], 1)
    tMatP = tf.reshape(tMatP, [kwargs.get('activeBatchSize'), 4, 4])
    tMatT = tf.reshape(tMatT, [kwargs.get('activeBatchSize'), 4, 4])
    # pclA should get a row of ones
    pclA = tf.concat([
        pclA,
        tf.constant(
            np.ones([kwargs.get('activeBatchSize'), 1,
                     kwargs.get('pclCols')],
                    dtype=np.float32))
    ], 1)
    pclP = tf.matmul(tMatP, pclA)
    pclT = tf.matmul(tMatT, pclA)
    return model_base.loss(pclP, pclT, **kwargs)
Esempio n. 2
0
def weighted_loss(tMatP, tMatT, **kwargs):
    mask = np.array([[100, 100, 100, 1, 100, 100, 100, 1, 100, 100, 100, 1]],
                    dtype=np.float32)
    mask = np.repeat(mask, kwargs.get('activeBatchSize'), axis=0)
    tMatP = tf.multiply(mask, tMatP)
    tMatT = tf.multiply(mask, tMatT)
    return model_base.loss(tMatP, tMatT, **kwargs)
Esempio n. 3
0
def loss(pred, target, **kwargs):  # batchSize=Sne
    """Add L2Loss to all the trainable variables.
    Add summary for "Loss" and "Loss/avg".
    Args:
      logits: Logits from inference().
      labels: Labels from distorted_inputs or inputs(). 1-D tensor
              of shape [batch_size, heatmap_size ]
    Returns:
      Loss tensor of type float.
    """
    return model_base.loss(pred, target, **kwargs)
Esempio n. 4
0
def weighted_params_loss(targetP, targetT, **kwargs):
    # Alpha, Beta, Gamma are -Pi to Pi periodic radians - mod over pi to remove periodicity
    mask = np.array([[np.pi, np.pi, np.pi, 1, 1, 1]], dtype=np.float32)
    mask = np.repeat(mask, kwargs.get('activeBatchSize'), axis=0)
    targetP = tf_mod(targetP, mask)
    targetT = tf_mod(targetT, mask)
    # Importance weigting on angles as they have smaller values
    mask = np.array([[1000, 1000, 1000, 1, 1, 1]], dtype=np.float32)
    mask = np.repeat(mask, kwargs.get('activeBatchSize'), axis=0)
    targetP = tf.multiply(targetP, mask)
    targetT = tf.multiply(targetT, mask)
    return model_base.loss(targetP, targetT, **kwargs)
Esempio n. 5
0
def loss(pHAB, tHAB, **kwargs):  # batchSize=Sne
    return model_base.loss(pHAB, tHAB, **kwargs)