images2D_carrier.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:lddmm-ot 作者: jeanfeydy 项目源码 文件源码
def _semi_lagrangian_displacement(self, v_sampled, grid_points, dt) :
        """
        Semi-Lagrangian scheme.
        Given a downsampled velocity field v (which  will be linearly interpolated),
        we find "where the information came from", i.e. numerically invert its
        flow during a time-step dt on the 'grid_points'.
        To do so, we simply solve the fixed point equation
        a(y)/2 = (dt/2) * v( y - a(y)/2 )
        by an "Picard-like" iterative scheme,
        where y is a grid point, and -a(y) the corresponding "backward" vector.
        """
        def f(r) :
            return .5 * dt * self._linear_interp_downsampledfield(v_sampled, grid_points - r)
        # Theano on GPU requires float32, i.e. explicit downcast from numpy float64 type :
        r_0 = np.zeros((np.prod(self.image_shape), self.image_dimension), dtype = config.floatX) 
        result, updates = theano.scan(fn            = f,          # Iterated routine
                                      outputs_info  = [r_0],      # Starting estimate for r
                                      n_steps       = 5)          # Number of iterations, sufficient in practice
        r_inf = result[-1]  # We only keep the end result
        return 2. * r_inf   # displacement "alpha"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号