diff --git a/docs/dect.html b/docs/dect.html index b23fa95..5fc761e 100644 --- a/docs/dect.html +++ b/docs/dect.html @@ -56,7 +56,7 @@

DECT - Differentiable Euler Characteristic Transform

-

arXiv GitHub contributors GitHub

+

arXiv GitHub contributors GitHub

This is the official implementation for the Differential Euler Characteristic Transform. Our implementation is fully optimized for hardware acceleration, @@ -117,7 +117,7 @@

Installation

Usage

-

For example usage, we provide the example.ipynb file and the code therein reproduces the +

For example usage, we provide the notebooks/example.ipynb file and the code therein reproduces the ECT of the gif of this readme. The code is provided on an as is basis. You are cordially invited to both contribute and provide feedback. Do not hesitate to contact us.

diff --git a/docs/dect/directions.html b/docs/dect/directions.html index 835ce1b..8e91f6d 100644 --- a/docs/dect/directions.html +++ b/docs/dect/directions.html @@ -40,9 +40,6 @@

API Documentation

  • generate_multiview_directions
  • -
  • - test_fn -
  • @@ -67,118 +64,102 @@

    -
      1"""
    -  2Helper function to generate a structured set of directions in 2 and 3
    -  3dimensions.
    -  4"""
    -  5
    -  6import itertools
    -  7import torch
    -  8
    -  9
    - 10def generate_uniform_directions(
    - 11    num_thetas: int = 64, d: int = 3, device: str = "cpu"
    - 12):
    - 13    """
    - 14    Generate randomly sampled directions from a sphere in d dimensions.
    - 15
    - 16    First a standard gaussian centered at 0 with standard deviation 1 is sampled
    - 17    and then projected onto the unit sphere. This yields a uniformly sampled set
    - 18    of points on the unit spere. Please note that the generated shapes with have
    - 19    shape [d, num_thetas].
    - 20
    - 21    Parameters
    - 22    ----------
    - 23    num_thetas: int
    - 24        The number of directions to generate.
    - 25    d: int
    - 26        The dimension of the unit sphere. Default is 3 (hence R^3)
    - 27    device: str
    - 28        The device to put the tensor on.
    - 29    """
    - 30    v = torch.randn(size=(d, num_thetas), device=device)
    - 31    v /= v.pow(2).sum(axis=0).sqrt().unsqueeze(1)
    - 32    return v
    - 33
    - 34
    - 35def generate_uniform_2d_directions(num_thetas: int = 64, device: str = "cpu"):
    - 36    """
    - 37    Generate uniformly sampled directions on the unit circle in two dimensions.
    - 38
    - 39    Provides a structured set of directions in two dimensions. First the
    - 40    interval [0,2*pi] is devided into a regular grid and the corresponding
    - 41    angles on the unit circle calculated.
    - 42
    - 43    Parameters
    - 44    ----------
    - 45    num_thetas: int
    - 46        The number of directions to generate.
    - 47    d: int
    - 48        The dimension of the unit sphere. Default is 3 (hence R^3)
    - 49    device: str
    - 50        The device to put the tensor on.
    - 51    """
    - 52    v = torch.vstack(
    - 53        [
    - 54            torch.sin(
    - 55                torch.linspace(0, 2 * torch.pi, num_thetas, device=device)
    - 56            ),
    - 57            torch.cos(
    - 58                torch.linspace(0, 2 * torch.pi, num_thetas, device=device)
    - 59            ),
    - 60        ]
    - 61    )
    - 62
    - 63    return v
    - 64
    - 65
    - 66def generate_multiview_directions(num_thetas: int, bump_steps: int, d: int):
    - 67    """
    - 68    Generates multiple sets of structured directions in n dimensions.
    - 69
    - 70    We generate sets of directions by embedding the 2d unit circle in d
    - 71    dimensions and sample this unit circle in a structured fashion. This
    - 72    generates d choose 2 structured directions that are organized in channels,
    - 73    compatible with the ECT calculations.
    - 74
    - 75    After computing the ECT, we obtain an d choose 2 channel image where each
    - 76    channel consists of a structured ect along a hyperplane. For the 3-d case we
    - 77    would obtain a 3 channel ect with direction sampled along the xy, xz and yz
    - 78    planes in three dimensions.
    - 79    """
    - 80    w = torch.vstack(
    - 81        [
    - 82            torch.sin(torch.linspace(0, 2 * torch.pi, bump_steps)),
    - 83            torch.cos(torch.linspace(0, 2 * torch.pi, bump_steps)),
    - 84        ]
    - 85    )
    - 86
    - 87    # We obtain n choose 2 channels.
    - 88    idx_pairs = list(itertools.combinations(range(d), r=2))
    - 89
    - 90    v = torch.zeros(size=(len(idx_pairs), d, num_thetas))
    - 91
    - 92    for idx, idx_pair in enumerate(idx_pairs):
    - 93        v[idx, idx_pair[0], :] = w[0]
    - 94        v[idx, idx_pair[1], :] = w[1]
    - 95
    - 96    return v
    - 97
    - 98
    - 99def test_fn():
    -100    """Yields
    -101    ------
    -102    err_code : int
    -103        Non-zero value indicates error code, or zero on success.
    -104    err_msg : str or None
    -105        Human readable error message, or None on success.
    -106
    -107    Returns
    -108    -------
    -109    int
    -110        Description of anonymous integer return value.
    -111
    -112    """
    +                        
     1"""
    + 2Helper function to generate a structured set of directions in 2 and 3
    + 3dimensions.
    + 4"""
    + 5
    + 6import itertools
    + 7import torch
    + 8
    + 9
    +10def generate_uniform_directions(
    +11    num_thetas: int = 64, d: int = 3, device: str = "cpu"
    +12):
    +13    """
    +14    Generate randomly sampled directions from a sphere in d dimensions.
    +15
    +16    First a standard gaussian centered at 0 with standard deviation 1 is sampled
    +17    and then projected onto the unit sphere. This yields a uniformly sampled set
    +18    of points on the unit spere. Please note that the generated shapes with have
    +19    shape [d, num_thetas].
    +20
    +21    Parameters
    +22    ----------
    +23    num_thetas: int
    +24        The number of directions to generate.
    +25    d: int
    +26        The dimension of the unit sphere. Default is 3 (hence R^3)
    +27    device: str
    +28        The device to put the tensor on.
    +29    """
    +30    v = torch.randn(size=(d, num_thetas), device=device)
    +31    v /= v.pow(2).sum(axis=0).sqrt().unsqueeze(1)
    +32    return v
    +33
    +34
    +35def generate_uniform_2d_directions(num_thetas: int = 64, device: str = "cpu"):
    +36    """
    +37    Generate uniformly sampled directions on the unit circle in two dimensions.
    +38
    +39    Provides a structured set of directions in two dimensions. First the
    +40    interval [0,2*pi] is devided into a regular grid and the corresponding
    +41    angles on the unit circle calculated.
    +42
    +43    Parameters
    +44    ----------
    +45    num_thetas: int
    +46        The number of directions to generate.
    +47    d: int
    +48        The dimension of the unit sphere. Default is 3 (hence R^3)
    +49    device: str
    +50        The device to put the tensor on.
    +51    """
    +52    v = torch.vstack(
    +53        [
    +54            torch.sin(
    +55                torch.linspace(0, 2 * torch.pi, num_thetas, device=device)
    +56            ),
    +57            torch.cos(
    +58                torch.linspace(0, 2 * torch.pi, num_thetas, device=device)
    +59            ),
    +60        ]
    +61    )
    +62
    +63    return v
    +64
    +65
    +66def generate_multiview_directions(num_thetas: int, bump_steps: int, d: int):
    +67    """
    +68    Generates multiple sets of structured directions in n dimensions.
    +69
    +70    We generate sets of directions by embedding the 2d unit circle in d
    +71    dimensions and sample this unit circle in a structured fashion. This
    +72    generates d choose 2 structured directions that are organized in channels,
    +73    compatible with the ECT calculations.
    +74
    +75    After computing the ECT, we obtain an d choose 2 channel image where each
    +76    channel consists of a structured ect along a hyperplane. For the 3-d case we
    +77    would obtain a 3 channel ect with direction sampled along the xy, xz and yz
    +78    planes in three dimensions.
    +79    """
    +80    w = torch.vstack(
    +81        [
    +82            torch.sin(torch.linspace(0, 2 * torch.pi, bump_steps)),
    +83            torch.cos(torch.linspace(0, 2 * torch.pi, bump_steps)),
    +84        ]
    +85    )
    +86
    +87    # We obtain n choose 2 channels.
    +88    idx_pairs = list(itertools.combinations(range(d), r=2))
    +89
    +90    v = torch.zeros(size=(len(idx_pairs), d, num_thetas))
    +91
    +92    for idx, idx_pair in enumerate(idx_pairs):
    +93        v[idx, idx_pair[0], :] = w[0]
    +94        v[idx, idx_pair[1], :] = w[1]
    +95
    +96    return v
     
    @@ -363,52 +344,6 @@
    Parameters
    - -
    - -
    - - def - test_fn(): - - - -
    - -
    100def test_fn():
    -101    """Yields
    -102    ------
    -103    err_code : int
    -104        Non-zero value indicates error code, or zero on success.
    -105    err_msg : str or None
    -106        Human readable error message, or None on success.
    -107
    -108    Returns
    -109    -------
    -110    int
    -111        Description of anonymous integer return value.
    -112
    -113    """
    -
    - - -
    Yields
    - -
      -
    • err_code (int): -Non-zero value indicates error code, or zero on success.
    • -
    • err_msg (str or None): -Human readable error message, or None on success.
    • -
    - -
    Returns
    - -
      -
    • int: Description of anonymous integer return value.
    • -
    -
    - -