def create_cost_bending(tn):
tn_shape = tn.get_shape().as_list();
tn1 = tf.slice(tn, [1,0], [-1,-1]);
tn2 = tf.slice(tn, [0,0], [tn_shape[0]-1,-1]);
dp = tf.reduce_sum(tf.mul(tn1, tn2), reduction_indices = 1);
return tf.scalar_mul(-1.0, tf.reduce_mean(dp));
#def create_cost_side(s, b, length = 1.0, weight_spacing = 1.0, weight_bending = 1.0):
# cost = create_cost_soft_min_distance(s, b);
# if weight_spacing != 0:
# cost_spacing = create_cost_spacing(s, length);
# cost = tf.add(cost, tf.mul(tf.constant(weight_spacing, "float32"), cost_spacing));
# if weight_bending != 0:
# cost_bending = create_cost_bending(s);
# cost = tf.add(cost, tf.mul(tf.constant(weight_bending, "float32"), cost_bending));
# return cost;
#def create_cost(c, w, b, nb, length, weight_spacing = 1.0, weight_bending = 1.0, gamma = 1.0, kappa = 2.0):
# #tangents
# t = create_tangent(c);
# tn = create_normalize_tangent(t);
# nl = create_normal(tn);
# nr = tf.scalar_mul(-1.0, nl);
#
# l,r = create_left_right(c,w,nl);
#
# cost_left = create_cost_soft_min_aligned_distance(l, b, nl, nb, k = kappa, gamma = gamma);
# cost_right= create_cost_soft_min_aligned_distance(r, b, nr, nb, k = kappa, gamma = gamma);
# cost = tf.add(cost_left, cost_right);
#
# #spacing and bending
# if weight_spacing != 0:
# cost_spacing = tf.scalar_mul(weight_spacing, create_cost_spacing(t, length));
# cost = tf.add(cost, cost_spacing);
# else:
# cost_spacing = tf.constant(0);
#
# if weight_bending != 0:
# cost_bending = tf.scalar_mul(weight_bending, create_cost_bending(tn));
# cost = tf.add(cost, cost_bending);
# else:
# cost_bending = tf.constant(0);
#
# return (cost, cost_left, cost_right, cost_spacing, cost_bending, nl, l, r);
machine_vision_d.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录