Beispiel #1
0
def chamfer_loss(A,B):    
    r=tf.reduce_sum(A*A,2)
    r=tf.reshape(r,[int(r.shape[0]),int(r.shape[1]),1])
    r2=tf.reduce_sum(B*B,2)
    r2=tf.reshape(r2,[int(r.shape[0]),int(r.shape[1]),1])
    t=(r-2*tf.matmul(A, tf.transpose(B,perm=[0, 2, 1])) + tf.transpose(r2,perm=[0, 2, 1]))
    return tf.reduce_mean((tf.reduce_min(t, axis=1)+tf.reduce_min(t,axis=2))/2.0)
Beispiel #2
0
def sg_min(tensor, opt):
    r"""Computes the minimum of elements across axis of a tensor.

    See `tf.reduce_min()` in tensorflow.

    Args:
      tensor: A `Tensor` (automatically given by chain).
      opt:
        axis : A tuple/list of integers or an integer. The axis to reduce.
        keep_dims: If true, retains reduced dimensions with length 1.
        name: If provided, replace current tensor's name.

    Returns:
      A `Tensor`.
    """
    return tf.reduce_min(tensor, axis=opt.axis, keep_dims=opt.keep_dims, name=opt.name)
Beispiel #3
0
def sg_min(tensor, opt):
    return tf.reduce_min(tensor,
                         reduction_indices=opt.dims,
                         keep_dims=opt.keep_dims,
                         name=opt.name)