def _meshgrid(self):
with tf.variable_scope('_meshgrid'):
x_use = tf.linspace(-1.0, 1.0, self.out_height)
y_use = tf.linspace(-1.0, 1.0, self.out_width)
z_use = tf.linspace(-1.0, 1.0, self.out_depth)
x_t = tf.tile(x_use,[self.out_width*self.out_depth])
y_t = tf.tile(self._repeat(y_use,self.out_height,'float32'),[self.out_depth])
z_t = self._repeat(z_use,self.out_height*self.out_width,'float32')
x_t_flat = tf.reshape(x_t, (1, -1))
y_t_flat = tf.reshape(y_t, (1, -1))
z_t_flat = tf.reshape(z_t, (1, -1))
px,py,pz = tf.stack([x_t_flat],axis=2),tf.stack([y_t_flat],axis=2),tf.stack([z_t_flat],axis=2)
#source control points
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)))
cpx,cpy,cpz = 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])
px, cpx = tf.meshgrid(px,cpx);py, cpy = tf.meshgrid(py,cpy); pz, cpz = tf.meshgrid(pz,cpz)
#Compute distance R
Rx,Ry,Rz = tf.square(tf.subtract(px,cpx)),tf.square(tf.subtract(py,cpy)),tf.square(tf.subtract(pz,cpz))
R = tf.add(tf.add(Rx,Ry),Rz)
R = tf.multiply(R,tf.log(tf.clip_by_value(R,1e-10,1e+10)))
#Source coordinates
ones = tf.ones_like(x_t_flat)
grid = tf.concat([ones, x_t_flat, y_t_flat,z_t_flat,R],0)
return grid
Dense_Transformer_Networks_3D.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录