{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "ada96372-65af-4b7a-ad62-ef74352328a3", "metadata": { "tags": [] }, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "\n", "import os\n", "import sys\n", "\n", "# Add the project's files to the python path\n", "# file_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # for .py script\n", "file_path = os.path.dirname(os.path.abspath('')) # for .ipynb notebook\n", "sys.path.append(file_path)\n", "\n", "import torch\n", "from src.datasets.s3dis import CLASS_NAMES, CLASS_COLORS, STUFF_CLASSES\n", "from src.datasets.s3dis import S3DIS_NUM_CLASSES as NUM_CLASSES\n", "from src.transforms import *" ] }, { "cell_type": "markdown", "id": "585172ca-bb12-40be-85ff-5e12f5c2a06e", "metadata": {}, "source": [ "The main data structures of this project are `Data` and `NAG`.\n", "\n", "`Data` stores a single-level graph. \n", "It inherits from `torch_geometric`'s `Data` and has a similar behavior (see the [official documentation](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.data.Data.html#torch_geometric.data.Data) for more on this). \n", "Important specificities of our `Data` object are:\n", "- `Data.super_index` stores the parent's index for each node in `Data`\n", "- `Data.sub` holds a `Cluster` object indicating the children of each node in `Data`\n", "- `Data.to_trimmed()` works like `torch_geometric`'s `Data.coalesce()` with the additional constraint that (i,j) and (j,i) edges are considered duplicates\n", "- `Data.save()` and `Data.load()` allow optimized, memory-friedly I/O operations\n", "- `Data.select()` indexes the nodes à la numpy\n", "\n", "`NAG` (Nested Acyclic Graph) stores the hierarchical partition in the form of a list of `Data` objects.\n", "Important specificities of our `Data` object are:\n", "- `NAG[i]` returns a `Data` object holding the partition level `ì`\n", "- `NAG.get_super_index()` returns the index mapping nodes from any level `i` to `j` with `i