def _makeT(self,cp):
with tf.variable_scope('_makeT'):
cp = tf.reshape(cp,(-1,3,self.X_controlP_number*self.Y_controlP_number*self.Z_controlP_number))
cp = tf.cast(cp,'float32')
N_f = tf.shape(cp)[0]
#c_s
x,y,z = tf.linspace(-1.,1.,self.X_controlP_number),tf.linspace(-1.,1.,self.Y_controlP_number),tf.linspace(-1.,1.,self.Z_controlP_number)
x = tf.tile(x,[self.Y_controlP_number*self.Z_controlP_number])
y = tf.tile(self._repeat(y,self.X_controlP_number,'float32'),[self.Z_controlP_number])
z = self._repeat(z,self.X_controlP_number*self.Y_controlP_number,'float32')
xs,ys,zs = tf.transpose(tf.reshape(x,(-1,1))),tf.transpose(tf.reshape(y,(-1,1))),tf.transpose(tf.reshape(z,(-1,1)))
cp_s = tf.concat([xs,ys,zs],0)
cp_s_trans = tf.transpose(cp_s)
# (4*4*4)*3 -> 64 * 3
##===Compute distance R
xs_trans,ys_trans,zs_trans = tf.transpose(tf.stack([xs],axis=2),perm=[1,0,2]),tf.transpose(tf.stack([ys],axis=2),perm=[1,0,2]),tf.transpose(tf.stack([zs],axis=2),perm=[1,0,2])
xs, xs_trans = tf.meshgrid(xs,xs_trans);ys, ys_trans = tf.meshgrid(ys,ys_trans);zs, zs_trans = tf.meshgrid(zs,zs_trans)
Rx,Ry, Rz = tf.square(tf.subtract(xs,xs_trans)),tf.square(tf.subtract(ys,ys_trans)),tf.square(tf.subtract(zs,zs_trans))
R = tf.add_n([Rx,Ry,Rz])
#print("R",sess.run(R))
R = tf.multiply(R,tf.log(tf.clip_by_value(R,1e-10,1e+10)))
#print("R",sess.run(R))
ones = tf.ones([self.Y_controlP_number*self.X_controlP_number*self.Z_controlP_number,1],tf.float32)
ones_trans = tf.transpose(ones)
zeros = tf.zeros([4,4],tf.float32)
Deltas1 = tf.concat([ones, cp_s_trans, R],1)
Deltas2 = tf.concat([ones_trans,cp_s],0)
Deltas2 = tf.concat([zeros,Deltas2],1)
Deltas = tf.concat([Deltas1,Deltas2],0)
#print("Deltas",sess.run(Deltas))
##get deltas_inv
Deltas_inv = tf.matrix_inverse(Deltas)
Deltas_inv = tf.expand_dims(Deltas_inv,0)
Deltas_inv = tf.reshape(Deltas_inv,[-1])
Deltas_inv_f = tf.tile(Deltas_inv,tf.stack([N_f]))
Deltas_inv_f = tf.reshape(Deltas_inv_f,tf.stack([N_f,self.X_controlP_number*self.Y_controlP_number*self.Z_controlP_number+4, -1]))
cp_trans =tf.transpose(cp,perm=[0,2,1])
zeros_f_In = tf.zeros([N_f,4,3],tf.float32)
cp = tf.concat([cp_trans,zeros_f_In],1)
#print("cp",sess.run(cp))
#print("Deltas_inv_f",sess.run(Deltas_inv_f))
T = tf.transpose(tf.matmul(Deltas_inv_f,cp),[0,2,1])
#print("T",sess.run(T))
return T
Dense_Transformer_Networks_3D.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录