@tf.function
def test_step(model, moving, static, criterion):
    'A generic testing procedure.\n\n    Parameters\n    ----------\n    model\n        A convolutional encoder-decoder network.\n    moving : tf.Tensor, shape (N, H, W, C)\n        A batch of moving images.\n    static : tf.Tensor, shape (1, H, W, C)\n        The static image.\n    criterion\n        The loss function.\n\n    Returns\n    -------\n    loss : tf.Tensor, shape ()\n        The average loss for the batch.\n    '
    (nb, nh, nw, nc) = moving.shape
    multiples = tf.constant([nb, 1, 1, 1], tf.int32)
    static = tf.tile(static, multiples)
    inputs = tf.concat([moving, static], axis=(- 1))
    deformation = model(inputs, training=False)
    grid = regular_grid([nb, nh, nw])
    grid_new = (grid + deformation)
    grid_new = tf.clip_by_value(grid_new, (- 1), 1)
    moved = grid_sample(moving, grid_new)
    loss = criterion(moved, static)
    return loss
A generic testing procedure.

Parameters
----------
model
    A convolutional encoder-decoder network.
moving : tf.Tensor, shape (N, H, W, C)
    A batch of moving images.
static : tf.Tensor, shape (1, H, W, C)
    The static image.
criterion
    The loss function.

Returns
-------
loss : tf.Tensor, shape ()
    The average loss for the batch.
@tf.function
def test_step(model, moving, static, criterion):
    'A generic testing procedure.\n\n    Parameters\n    ----------\n    model\n        A convolutional encoder-decoder network.\n    moving : tf.Tensor, shape (N, H, W, C)\n        A batch of moving images.\n    static : tf.Tensor, shape (1, H, W, C)\n        The static image.\n    criterion\n        The loss function.\n\n    Returns\n    -------\n    loss : tf.Tensor, shape ()\n        The average loss for the batch.\n    '
    (nb, nh, nw, nc) = moving.shape
    multiples = tf.constant([nb, 1, 1, 1], tf.int32)
    static = tf.tile(static, multiples)
    inputs = tf.concat([moving, static], axis=(- 1))
    deformation = model(inputs, training=False)
    grid = regular_grid([nb, nh, nw])
    grid_new = (grid + deformation)
    grid_new = tf.clip_by_value(grid_new, (- 1), 1)
    moved = grid_sample(moving, grid_new)
    loss = criterion(moved, static)
    return loss