Skip to content

Commit

Permalink
Deploying to main from @ pyt-team/TopoModelX@62ee00c 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
jkhouja committed Oct 9, 2023
1 parent 006cef0 commit 8c0d6fb
Show file tree
Hide file tree
Showing 222 changed files with 520 additions and 468 deletions.
Binary file modified topomodelx/.doctrees/environment.pickle
Binary file not shown.
9 changes: 4 additions & 5 deletions topomodelx/.doctrees/nbsphinx/notebooks/cell/can_train.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@
"import torch.nn.functional as F\n",
"\n",
"\n",
"from topomodelx.nn.cell.can import CAN"
"from topomodelx.nn.cell.can import CAN\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -253,14 +254,12 @@
" adjacency_0_list.append(adjacency_0)\n",
"\n",
" lower_neighborhood_t = cell_complex.down_laplacian_matrix(rank=1)\n",
" lower_neighborhood_t = torch.from_numpy(lower_neighborhood_t.todense()).to_sparse()\n",
" lower_neighborhood_t = from_sparse(lower_neighborhood_t)\n",
" lower_neighborhood_list.append(lower_neighborhood_t)\n",
"\n",
" try:\n",
" upper_neighborhood_t = cell_complex.up_laplacian_matrix(rank=1)\n",
" upper_neighborhood_t = torch.from_numpy(\n",
" upper_neighborhood_t.todense()\n",
" ).to_sparse()\n",
" upper_neighborhood_t = from_sparse(upper_neighborhood_t)\n",
" except:\n",
" upper_neighborhood_t = np.zeros(\n",
" (lower_neighborhood_t.shape[0], lower_neighborhood_t.shape[0])\n",
Expand Down
7 changes: 4 additions & 3 deletions topomodelx/.doctrees/nbsphinx/notebooks/cell/ccxn_train.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"import toponetx.datasets as datasets\n",
"\n",
"\n",
"from topomodelx.nn.cell.ccxn import CCXN"
"from topomodelx.nn.cell.ccxn import CCXN\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -194,8 +195,8 @@
"\n",
" incidence_2_t = cell_complex.incidence_matrix(rank=2).T\n",
" adjacency_0 = cell_complex.adjacency_matrix(rank=0)\n",
" incidence_2_t = torch.from_numpy(incidence_2_t.todense()).to_sparse()\n",
" adjacency_0 = torch.from_numpy(adjacency_0.todense()).to_sparse()\n",
" incidence_2_t = from_sparse(incidence_2_t)\n",
" adjacency_0 = from_sparse(adjacency_0)\n",
" incidence_2_t_list.append(incidence_2_t)\n",
" adjacency_0_list.append(adjacency_0)"
]
Expand Down
9 changes: 5 additions & 4 deletions topomodelx/.doctrees/nbsphinx/notebooks/cell/cwn_train.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"\n",
"import toponetx.datasets as datasets\n",
"\n",
"from topomodelx.nn.cell.cwn import CWN"
"from topomodelx.nn.cell.cwn import CWN\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -222,9 +223,9 @@
" adjacency_1 = cell_complex.adjacency_matrix(rank=1)\n",
" incidence_1_t = cell_complex.incidence_matrix(rank=1).T\n",
"\n",
" incidence_2 = torch.from_numpy(incidence_2.todense()).to_sparse()\n",
" adjacency_1 = torch.from_numpy(adjacency_1.todense()).to_sparse()\n",
" incidence_1_t = torch.from_numpy(incidence_1_t.todense()).to_sparse()\n",
" incidence_2 = from_sparse(incidence_2)\n",
" adjacency_1 = from_sparse(adjacency_1)\n",
" incidence_1_t = from_sparse(incidence_1_t)\n",
"\n",
" incidence_2_list.append(incidence_2)\n",
" adjacency_1_list.append(adjacency_1)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"from sklearn.model_selection import train_test_split\n",
"import toponetx.datasets as datasets\n",
"\n",
"from topomodelx.nn.hypergraph.allset import AllSet"
"from topomodelx.nn.hypergraph.allset import AllSet\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -196,7 +197,7 @@
"incidence_1_list = []\n",
"for simplex in simplexes:\n",
" incidence_1 = simplex.incidence_matrix(rank=1, signed=False)\n",
" # incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
" # incidence_1 = from_sparse(incidence_1)\n",
" # incidence_1_list.append(incidence_1)\n",
" hg = simplex.to_hypergraph()\n",
" hg_list.append(hg)\n",
Expand All @@ -205,7 +206,7 @@
"# Extract hypergraphs incident matrices from collected hypergraphs\n",
"for hg in hg_list:\n",
" incidence_1 = hg.incidence_matrix()\n",
" incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
" incidence_1 = from_sparse(incidence_1)\n",
" incidence_1_list.append(incidence_1)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"from sklearn.model_selection import train_test_split\n",
"\n",
"from topomodelx.nn.hypergraph.allset_transformer import AllSetTransformer\n",
"from topomodelx.utils.sparse import from_sparse\n",
"\n",
"# %load_ext autoreload\n",
"# %autoreload 2"
Expand Down Expand Up @@ -236,7 +237,7 @@
"# Extract hypergraphs incident matrices from collected hypergraphs\n",
"for hg in hg_list:\n",
" incidence_1 = hg.incidence_matrix()\n",
" incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
" incidence_1 = from_sparse(incidence_1)\n",
" incidence_1_list.append(incidence_1)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"from sklearn.model_selection import train_test_split\n",
"\n",
"import toponetx.datasets as datasets\n",
"from topomodelx.nn.hypergraph.dhgcn import DHGCN"
"from topomodelx.nn.hypergraph.dhgcn import DHGCN\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -204,7 +205,7 @@
"incidence_1_list = []\n",
"for simplex in simplexes:\n",
" incidence_1 = simplex.incidence_matrix(rank=1, signed=False)\n",
" incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
" incidence_1 = from_sparse(incidence_1)\n",
" incidence_1_list.append(incidence_1)\n",
" hg = simplex.to_hypergraph()\n",
" hg_list.append(hg)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"import toponetx.datasets.graph as graph\n",
"from topomodelx.nn.hypergraph.hnhn_layer import HNHNLayer\n",
"import matplotlib.pyplot as plt\n",
"from topomodelx.nn.hypergraph.hnhn import HNHN, HNHNNetwork"
"from topomodelx.nn.hypergraph.hnhn import HNHN, HNHNNetwork\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -119,7 +120,7 @@
],
"source": [
"incidence_1 = dataset_sim.incidence_matrix(rank=1, signed=False)\n",
"incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
"incidence_1 = from_sparse(incidence_1)\n",
"print(f\"The incidence matrix B1 has shape: {incidence_1.shape}.\")"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"import toponetx.datasets as datasets\n",
"from sklearn.model_selection import train_test_split\n",
"\n",
"from topomodelx.nn.hypergraph.hypergat import HyperGAT"
"from topomodelx.nn.hypergraph.hypergat import HyperGAT\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -177,7 +178,7 @@
"# Extract hypergraphs incident matrices from collected hypergraphs\n",
"for hg in hg_list:\n",
" incidence_1 = hg.incidence_matrix()\n",
" incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
" incidence_1 = from_sparse(incidence_1)\n",
" incidence_1_list.append(incidence_1)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"import toponetx.datasets as datasets\n",
"from sklearn.model_selection import train_test_split\n",
"\n",
"from topomodelx.nn.hypergraph.hypersage import HyperSAGE"
"from topomodelx.nn.hypergraph.hypersage import HyperSAGE\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -164,7 +165,7 @@
"# Extract hypergraphs incident matrices from collected hypergraphs\n",
"for hg in hg_list:\n",
" incidence_1 = hg.incidence_matrix()\n",
" incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
" incidence_1 = from_sparse(incidence_1)\n",
" incidence_1_list.append(incidence_1)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"from torch_geometric.datasets import TUDataset\n",
"from torch_geometric.utils.convert import to_networkx\n",
"from toponetx.classes.simplicial_complex import SimplicialComplex\n",
"from topomodelx.nn.hypergraph.unigin import UniGIN"
"from topomodelx.nn.hypergraph.unigin import UniGIN\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -58,7 +59,7 @@
"incidence_1_list = []\n",
"for hg in hg_list:\n",
" incidence_1 = hg.incidence_matrix()\n",
" incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
" incidence_1 = from_sparse(incidence_1)\n",
" incidence_1_list.append(incidence_1)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"import toponetx.datasets.graph as graph\n",
"\n",
"from topomodelx.nn.simplicial.dist2cycle import Dist2Cycle\n",
"from topomodelx.utils.sparse import from_sparse\n",
"import numpy.linalg as npla"
]
},
Expand Down Expand Up @@ -101,8 +102,8 @@
"incidence_1 = dataset.incidence_matrix(rank=1)\n",
"adjacency_0 = dataset.adjacency_matrix(rank=0)\n",
"\n",
"incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
"adjacency_0 = torch.from_numpy(adjacency_0.todense()).to_sparse()\n",
"incidence_1 = from_sparse(incidence_1)\n",
"adjacency_0 = from_sparse(adjacency_0)\n",
"\n",
"print(f\"The incidence matrix B1 has shape: {incidence_1.shape}.\")\n",
"print(f\"The adjacency matrix A0 has shape: {adjacency_0.shape}.\")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"\n",
"import toponetx.datasets.graph as graph\n",
"\n",
"from topomodelx.nn.simplicial.hsn import HSN"
"from topomodelx.nn.simplicial.hsn import HSN\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -103,8 +104,8 @@
"incidence_1 = dataset.incidence_matrix(rank=1)\n",
"adjacency_0 = dataset.adjacency_matrix(rank=0)\n",
"\n",
"incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
"adjacency_0 = torch.from_numpy(adjacency_0.todense()).to_sparse()\n",
"incidence_1 = from_sparse(incidence_1)\n",
"adjacency_0 = from_sparse(adjacency_0)\n",
"\n",
"print(f\"The incidence matrix B1 has shape: {incidence_1.shape}.\")\n",
"print(f\"The adjacency matrix A0 has shape: {adjacency_0.shape}.\")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"from torch_geometric.utils.convert import to_networkx\n",
"\n",
"from topomodelx.nn.simplicial.san import SAN\n",
"from topomodelx.utils.sparse import from_sparse\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2"
Expand Down Expand Up @@ -201,18 +202,14 @@
"simplex_order_k = 1\n",
"# Down laplacian\n",
"try:\n",
" laplacian_down = torch.from_numpy(\n",
" dataset.down_laplacian_matrix(rank=simplex_order_k).todense()\n",
" ).to_sparse()\n",
" laplacian_down = from_sparse(dataset.down_laplacian_matrix(rank=simplex_order_k))\n",
"except ValueError:\n",
" laplacian_down = torch.zeros(\n",
" (dataset.shape[simplex_order_k], dataset.shape[simplex_order_k])\n",
" ).to_sparse()\n",
"# Up laplacian\n",
"try:\n",
" laplacian_up = torch.from_numpy(\n",
" dataset.up_laplacian_matrix(rank=simplex_order_k).todense()\n",
" ).to_sparse()\n",
" laplacian_up = from_sparse(dataset.up_laplacian_matrix(rank=simplex_order_k))\n",
"except ValueError:\n",
" laplacian_up = torch.zeros(\n",
" (dataset.shape[simplex_order_k], dataset.shape[simplex_order_k])\n",
Expand Down Expand Up @@ -288,7 +285,7 @@
},
"outputs": [],
"source": [
"incidence_0_1 = torch.from_numpy(dataset.incidence_matrix(1).todense()).to_sparse()"
"incidence_0_1 = from_sparse(dataset.incidence_matrix(1))"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"import toponetx.datasets as datasets\n",
"from sklearn.model_selection import train_test_split\n",
"\n",
"from topomodelx.nn.simplicial.sca_cmps import SCACMPS"
"from topomodelx.nn.simplicial.sca_cmps import SCACMPS\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -159,10 +160,10 @@
" incidence_1_t = sc.incidence_matrix(rank=1).T\n",
" incidence_2_t = sc.incidence_matrix(rank=2).T\n",
"\n",
" laplacian_down_1 = torch.from_numpy(laplacian_down_1.todense()).to_sparse()\n",
" laplacian_down_2 = torch.from_numpy(laplacian_down_2.todense()).to_sparse()\n",
" incidence_1_t = torch.from_numpy(incidence_1_t.todense()).to_sparse()\n",
" incidence_2_t = torch.from_numpy(incidence_2_t.todense()).to_sparse()\n",
" laplacian_down_1 = from_sparse(laplacian_down_1)\n",
" laplacian_down_2 = from_sparse(laplacian_down_2)\n",
" incidence_1_t = from_sparse(incidence_1_t)\n",
" incidence_2_t = from_sparse(incidence_2_t)\n",
"\n",
" laplacian_down_1_list.append(laplacian_down_1)\n",
" laplacian_down_2_list.append(laplacian_down_2)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"\n",
"import toponetx.datasets.graph as graph\n",
"\n",
"from topomodelx.nn.simplicial.sccn import SCCN"
"from topomodelx.nn.simplicial.sccn import SCCN\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -131,7 +132,7 @@
],
"source": [
"def sparse_to_torch(X):\n",
" return torch.from_numpy(X.todense()).to_sparse()\n",
" return from_sparse(X)\n",
"\n",
"\n",
"incidences = {\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"import numpy as np\n",
"from sklearn.model_selection import train_test_split\n",
"import toponetx.datasets as datasets\n",
"from topomodelx.nn.simplicial.sccnn import SCCNN, SCCNNComplex"
"from topomodelx.nn.simplicial.sccnn import SCCNN, SCCNNComplex\n",
"from topomodelx.utils.sparse import from_sparse"
]
},
{
Expand Down Expand Up @@ -164,12 +165,12 @@
" laplacian_up_1 = simplex.up_laplacian_matrix(rank=1)\n",
" laplacian_2 = simplex.hodge_laplacian_matrix(rank=2)\n",
"\n",
" incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
" incidence_2 = torch.from_numpy(incidence_2.todense()).to_sparse()\n",
" laplacian_0 = torch.from_numpy(laplacian_0.todense()).to_sparse()\n",
" laplacian_down_1 = torch.from_numpy(laplacian_down_1.todense()).to_sparse()\n",
" laplacian_up_1 = torch.from_numpy(laplacian_up_1.todense()).to_sparse()\n",
" laplacian_2 = torch.from_numpy(laplacian_2.todense()).to_sparse()\n",
" incidence_1 = from_sparse(incidence_1)\n",
" incidence_2 = from_sparse(incidence_2)\n",
" laplacian_0 = from_sparse(laplacian_0)\n",
" laplacian_down_1 = from_sparse(laplacian_down_1)\n",
" laplacian_up_1 = from_sparse(laplacian_up_1)\n",
" laplacian_2 = from_sparse(laplacian_2)\n",
"\n",
" incidence_1_list.append(incidence_1)\n",
" incidence_2_list.append(incidence_2)\n",
Expand Down Expand Up @@ -526,14 +527,14 @@
"metadata": {},
"outputs": [],
"source": [
"laplacian_0 = torch.from_numpy(laplacian_0.todense()).to_sparse()\n",
"laplacian_down_1 = torch.from_numpy(laplacian_down_1.todense()).to_sparse()\n",
"laplacian_up_1 = torch.from_numpy(laplacian_up_1.todense()).to_sparse()\n",
"laplacian_down_2 = torch.from_numpy(laplacian_down_2.todense()).to_sparse()\n",
"laplacian_up_2 = torch.from_numpy(laplacian_up_2.todense()).to_sparse()\n",
"\n",
"incidence_1 = torch.from_numpy(incidence_1.todense()).to_sparse()\n",
"incidence_2 = torch.from_numpy(incidence_2.todense()).to_sparse()"
"laplacian_0 = from_sparse(laplacian_0)\n",
"laplacian_down_1 = from_sparse(laplacian_down_1)\n",
"laplacian_up_1 = from_sparse(laplacian_up_1)\n",
"laplacian_down_2 = from_sparse(laplacian_down_2)\n",
"laplacian_up_2 = from_sparse(laplacian_up_2)\n",
"\n",
"incidence_1 = from_sparse(incidence_1)\n",
"incidence_2 = from_sparse(incidence_2)"
]
},
{
Expand Down
Loading

0 comments on commit 8c0d6fb

Please sign in to comment.