Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding loss regularization #20

Open
topinfrassi01 opened this issue Jun 1, 2021 · 0 comments
Open

Question regarding loss regularization #20

topinfrassi01 opened this issue Jun 1, 2021 · 0 comments

Comments

@topinfrassi01
Copy link
Contributor

Hi,

I was intrigued regarding the constants we can find in the mesh_loss function (for example the *500 on edge_loss) so I looked at your paper but I didn't find any mention of these, I assume they are regularization constants.

I have two questions regarding these constants :

  • it seems like there is a factor of 3000 that appears in every loss, (3000 for chamfer_loss which isn't regularized, 1500 for laplace_loss` which would indicate a regularization factor of 0.5). What is the number 3000 based on?
  • the same goes for the 0.55 value at tf.reduce_mean(dist2) in chamfer loss. What is this number?
def laplace_loss_2(pred1, pred2, placeholders, block_id):
    # laplace term
    lap1 = laplace_coord(pred1, placeholders, block_id)
    lap2 = laplace_coord(pred2, placeholders, block_id)
    laplace_loss = tf.reduce_mean(tf.reduce_sum(tf.square(tf.subtract(lap1, lap2)), 1)) * 1500
    move_loss = tf.reduce_mean(tf.reduce_sum(tf.square(tf.subtract(pred1, pred2)), 1)) * 100
    return laplace_loss + move_loss

def mesh_loss_2(pred, placeholders, block_id):
    gt_pt = placeholders['labels'][:, :3]  # gt points
    gt_nm = placeholders['labels'][:, 3:]  # gt normals

    # edge in graph
    nod1 = tf.gather(pred, placeholders['edges'][block_id - 1][:, 0])
    nod2 = tf.gather(pred, placeholders['edges'][block_id - 1][:, 1])
    edge = tf.subtract(nod1, nod2)

    # edge length loss
    edge_length = tf.reduce_sum(tf.square(edge), 1)
    edge_loss = tf.reduce_mean(edge_length) * 500

    # chamfer distance
    sample_pt = sample(pred, placeholders, block_id)
    sample_pred = tf.concat([pred, sample_pt], axis=0)
    dist1, idx1, dist2, idx2 = nn_distance(gt_pt, sample_pred)
    point_loss = (tf.reduce_mean(dist1) + 0.55 * tf.reduce_mean(dist2)) * 3000

    # normal cosine loss
    normal = tf.gather(gt_nm, tf.squeeze(idx2, 0))
    normal = tf.gather(normal, placeholders['edges'][block_id - 1][:, 0])
    cosine = tf.abs(tf.reduce_sum(tf.multiply(unit(normal), unit(edge)), 1))
    normal_loss = tf.reduce_mean(cosine) * 0.5

    total_loss = point_loss + edge_loss + normal_loss
    return total_loss

I notice the same question was asked on the Pixel2Mesh repository here but there are no answer. Hopefully we could kill two birds with one stone with an answer here or there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant