-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applying black to previous changes. Adding a simplicial dataloader an…
…d some transforms that add data to the simplicial complexes such as neighborhood matrices. Experiments with simplicial complex neural networks started in experiment_scconv.ipynb, but still not available.
- Loading branch information
Showing
7 changed files
with
624 additions
and
79 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"%load_ext autoreload\n", | ||
"%autoreload 2" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-04-26T15:57:14.612479Z", | ||
"start_time": "2024-04-26T15:57:14.576630Z" | ||
} | ||
}, | ||
"id": "e1447e3b250fa124", | ||
"execution_count": 1 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [ | ||
{ | ||
"ename": "ModuleNotFoundError", | ||
"evalue": "No module named 'topomodelx'", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001B[1;31m---------------------------------------------------------------------------\u001B[0m", | ||
"\u001B[1;31mModuleNotFoundError\u001B[0m Traceback (most recent call last)", | ||
"Cell \u001B[1;32mIn[35], line 7\u001B[0m\n\u001B[0;32m 5\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mmantra\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mtransforms\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m OrientableToClassTransform, SimplicialComplexTransform\n\u001B[0;32m 6\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mmantra\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mdataloaders\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m SimplicialDataLoader\n\u001B[1;32m----> 7\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mtopomodelx\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mutils\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01msparse\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m from_sparse\n", | ||
"\u001B[1;31mModuleNotFoundError\u001B[0m: No module named 'topomodelx'" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from mantra.simplicial import SimplicialDataset\n", | ||
"import torch\n", | ||
"import numpy as np\n", | ||
"import torchvision.transforms as transforms\n", | ||
"from mantra.transforms import OrientableToClassTransform, SimplicialComplexTransform\n", | ||
"from mantra.dataloaders import SimplicialDataLoader\n", | ||
"from topomodelx.utils.sparse import from_sparse" | ||
], | ||
"metadata": { | ||
"collapsed": true, | ||
"ExecuteTime": { | ||
"end_time": "2024-04-26T16:17:56.006222Z", | ||
"start_time": "2024-04-26T16:17:55.890296Z" | ||
} | ||
}, | ||
"id": "initial_id", | ||
"execution_count": 35 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mantra.transforms import SimplicialComplexDegreeTransform, SimplicialComplexEdgeCoadjacencyDegreeTransform, \\\n", | ||
" SimplicialComplexEdgeAdjacencyDegreeTransform, SimplicialComplexTriangleCoadjacencyDegreeTransform, \\\n", | ||
" OrientableToClassSimplicialComplexTransform, DimTwoHodgeLaplacianSimplicialComplexTransform, \\\n", | ||
" DimOneHodgeLaplacianDownSimplicialComplexTransform, DimOneHodgeLaplacianUpSimplicialComplexTransform, \\\n", | ||
" DimZeroHodgeLaplacianSimplicialComplexTransform\n", | ||
"\n", | ||
"tr = transforms.Compose(\n", | ||
" [SimplicialComplexTransform(), \n", | ||
" SimplicialComplexDegreeTransform(),\n", | ||
" SimplicialComplexEdgeCoadjacencyDegreeTransform(),\n", | ||
" SimplicialComplexEdgeAdjacencyDegreeTransform(),\n", | ||
" SimplicialComplexTriangleCoadjacencyDegreeTransform(),\n", | ||
" DimZeroHodgeLaplacianSimplicialComplexTransform(),\n", | ||
" DimOneHodgeLaplacianUpSimplicialComplexTransform(),\n", | ||
" DimOneHodgeLaplacianDownSimplicialComplexTransform(),\n", | ||
" DimTwoHodgeLaplacianSimplicialComplexTransform(),\n", | ||
" OrientableToClassSimplicialComplexTransform()]\n", | ||
" )" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-04-26T16:16:25.339696Z", | ||
"start_time": "2024-04-26T16:16:25.243304Z" | ||
} | ||
}, | ||
"id": "258c13ed23fc24a9", | ||
"execution_count": 32 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"dataset = SimplicialDataset(root=\"./data\", transform=tr)\n", | ||
"dloader = SimplicialDataLoader(dataset, batch_size=3, shuffle=False)" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-04-26T16:16:25.802979Z", | ||
"start_time": "2024-04-26T16:16:25.696147Z" | ||
} | ||
}, | ||
"id": "b7a030f18bfe7035", | ||
"execution_count": 33 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[tensor([[3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.]]), tensor([[4.],\n", | ||
" [3.],\n", | ||
" [4.],\n", | ||
" [4.],\n", | ||
" [3.]]), tensor([[5.],\n", | ||
" [3.],\n", | ||
" [4.],\n", | ||
" [5.],\n", | ||
" [4.],\n", | ||
" [3.]])]\n", | ||
"[tensor([[4., 4.],\n", | ||
" [4., 4.],\n", | ||
" [4., 4.],\n", | ||
" [4., 4.],\n", | ||
" [4., 4.],\n", | ||
" [4., 4.]]), tensor([[5., 4.],\n", | ||
" [6., 4.],\n", | ||
" [6., 4.],\n", | ||
" [5., 4.],\n", | ||
" [5., 4.],\n", | ||
" [5., 4.],\n", | ||
" [6., 4.],\n", | ||
" [5., 4.],\n", | ||
" [5., 4.]]), tensor([[6., 4.],\n", | ||
" [7., 4.],\n", | ||
" [8., 4.],\n", | ||
" [7., 4.],\n", | ||
" [6., 4.],\n", | ||
" [5., 4.],\n", | ||
" [6., 4.],\n", | ||
" [7., 4.],\n", | ||
" [6., 4.],\n", | ||
" [7., 4.],\n", | ||
" [6., 4.],\n", | ||
" [5., 4.]])]\n", | ||
"[tensor([[3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.]]), tensor([[3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.]]), tensor([[3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.],\n", | ||
" [3.]])]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Take the first batch\n", | ||
"batch, signals_belonging, len_batch = next(iter(dloader))" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-04-26T16:16:32.741466Z", | ||
"start_time": "2024-04-26T16:16:32.618291Z" | ||
} | ||
}, | ||
"id": "3220794957955b0f", | ||
"execution_count": 34 | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.