quantnn/generic/__init__.py
def pad_zeros(module, array, n, dimension):
    """
    Pads array with 0s along given dimension.

    Args:
        module: Module object corresponding to the arrays.
        array: The array to pad.
        n: The number of zeros to add to each edge.
        dimension: Along which dimension to add zeros.

    Returns:
        A new array with the given number of 0s added to
        each edge along the given dimension.
    """
    _import_modules()
    if module in [np, ma, jnp, tf]:
        n_dims = len(array.shape)
        pad = [(0, 0)] * n_dims
        pad[dimension] = (n, n)
        return module.pad(array, pad, mode="constant", constant_values=0.0)
    elif module == torch:
        n_dims = len(array.shape)
        dimension = dimension % n_dims
        pad = [0] * 2 * n_dims
        pad[2 * n_dims - 2 - 2 * dimension] = n
        pad[2 * n_dims - 1 - 2 * dimension] = n
        return module.nn.functional.pad(array, pad, "constant", 0.0)
    raise UnknownModuleException(f"Module {module.__name__} not supported.")

    Pads array with 0s along given dimension.

    Args:
        module: Module object corresponding to the arrays.
        array: The array to pad.
        n: The number of zeros to add to each edge.
        dimension: Along which dimension to add zeros.

    Returns:
        A new array with the given number of 0s added to
        each edge along the given dimension.
    
Pads array with 0s along given dimension.
Pads array with 0s along given dimension .
def pad_zeros(module, array, n, dimension):
    _import_modules()
    if module in [np, ma, jnp, tf]:
        n_dims = len(array.shape)
        pad = [(0, 0)] * n_dims
        pad[dimension] = (n, n)
        return module.pad(array, pad, mode="constant", constant_values=0.0)
    elif module == torch:
        n_dims = len(array.shape)
        dimension = dimension % n_dims
        pad = [0] * 2 * n_dims
        pad[2 * n_dims - 2 - 2 * dimension] = n
        pad[2 * n_dims - 1 - 2 * dimension] = n
        return module.nn.functional.pad(array, pad, "constant", 0.0)
    raise UnknownModuleException(f"Module {module.__name__} not supported.")
def pad_zeros ( module , array , n , dimension ) : _import_modules ( ) if module in [ np , ma , jnp , tf ] : n_dims = len ( array . shape ) pad = [ ( 0 , 0 ) ] * n_dims pad [ dimension ] = ( n , n ) return module . pad ( array , pad , mode = "constant" , constant_values = 0.0 ) elif module == torch : n_dims = len ( array . shape ) dimension = dimension % n_dims pad = [ 0 ] * 2 * n_dims pad [ 2 * n_dims - 2 - 2 * dimension ] = n pad [ 2 * n_dims - 1 - 2 * dimension ] = n return module . nn . functional . pad ( array , pad , "constant" , 0.0 ) raise UnknownModuleException ( f"Module {module.__name__} not supported." )
Pads array with 0s along given dimension.
Pads array with 0s along given dimension .
"""
    Pads array with 0s along given dimension.

    Args:
        module: Module object corresponding to the arrays.
        array: The array to pad.
        n: The number of zeros to add to each edge.
        dimension: Along which dimension to add zeros.

    Returns:
        A new array with the given number of 0s added to
        each edge along the given dimension.
    """
A new array with the given number of 0s added to
each edge along the given dimension.
A new array with the given number of 0s added to each edge along the given dimension .
module
Module object corresponding to the arrays.
Module object corresponding to the arrays .
array
The array to pad.
The array to pad .
n
The number of zeros to add to each edge.
The number of zeros to add to each edge .
dimension
Along which dimension to add zeros.
Along which dimension to add zeros .