-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notebook orbit5k #99
Notebook orbit5k #99
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
nberkouk seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! :-) Only some small changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small changes. The most important one is preprocessing.
examples/orbit_5k_pipeline.ipynb
Outdated
"\n", | ||
"The goal of ths notebook is to classify the orbits and infer the parameter $\\alpha$ that was used to generate such orbits." | ||
"$$ x_{n+1} = x_{n} + \\rho y_n(1-y_n) ~~~\\text{mod }1$$\n", | ||
"$$ y_{n+1} = y_{n} + \\rho x_n(1-x_{n+1}) ~~~\\text{mod }1$$\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
y_{n+1} = y_{n} + \rho x_{n+1}(1-x_{n+1})
"$$ x_{n+1} = x_{n} + \\rho y_n(1-y_n) ~~~\\text{mod }1$$\n", | ||
"$$ y_{n+1} = y_{n} + \\rho x_n(1-x_{n+1}) ~~~\\text{mod }1$$\n", | ||
"\n", | ||
"3. Define $S^\\rho := \\{(x_i,y_i) \\mid i = 0...999 \\}$\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this version it's a 1.
https://github.com/giotto-ai/giotto-deep/blob/notebook_orbit5k/examples/orbit_5k_pipeline.ipynb
"\n", | ||
"import torch\n", | ||
"import torch.nn as nn\n", | ||
"\n", | ||
"# Gdeep imports \n", | ||
"\n", | ||
"from gdeep.data import PreprocessingPipeline\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preprocessing is missing in the pipeline.
examples/orbit_5k_pipeline.ipynb
Outdated
" num_attention_layers=2,\n", | ||
" num_attention_heads=8,\n", | ||
")\n", | ||
"\n", | ||
"wrapped_model = PersformerWrapper(\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you redefine the model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a comment why we need a wrapped Persformer model
examples/orbit_5k_pipeline.ipynb
Outdated
@@ -121,6 +184,15 @@ | |||
"source": [ | |||
"# Define the model by using a Wrapper for the Persformer model\n", | |||
"\n", | |||
"model_config = PersformerConfig(\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you define the model config
"batch = next(iter(dl_train))\n", | ||
"datum = batch[0][0].reshape(1, *(batch[0][0].shape))\n", | ||
"class_ = batch[1][0].item()\n", | ||
"\n", | ||
"# we now the Saliency maps to interpret the results\n", | ||
"inter = Interpreter(trainer.model, method=\"Saliency\")\n", | ||
"\n", | ||
"# interpret the diagram\n", | ||
"x, attr = inter.interpret(x=datum, y=class_)\n", | ||
"\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new section explaining why you're doing hyperparameter search
@@ -155,14 +271,16 @@ | |||
"metadata": {}, | |||
"outputs": [], | |||
"source": [ | |||
"# get a datum and its corresponding class\n", | |||
"# Initialize the Interpreter class in Saliency mode\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interpreter class -> Interpreter object
"\n", | ||
"One of the key feature of the Persformer achitecture, is that it is proven to satisfy a Universal Approximation Theorem. The authors of the [Persformer paper](https://arxiv.org/abs/2112.15210) also give evidence that this achitecture has less inductive bias than already existing deep neural networks architecture that can input persistence diagrams. This observation motivates the introduction of importance score of points in persistence diagrams in a classification task.\n", | ||
" \n", | ||
"The $\\textbf{Persformer}$ model for a classification problem is an almost everywhere differentiable function $F: \\mathcal D \\to \\mathbb{R}^m$, where $m$ is the number of classes and $\\mathcal D$ is the space of persistence diagrams. It maps a persistence diagram to the logits of the class probability. Let $d$ be the maximum homology dimension to be considered and let $x = (x_k)_{k\\in \\{ 1,\\ldots, n \\}}\\in (\\R^{2+d})^n$ be a persistence diagram and $i(x) = \\mathrm{argmax}_j F(x)_j$. The first two coordinates of $x_k \\in \\mathbb{R}^{2+d}$ are the birth and death coordinates and the last $d$ coordinates are the one-hot encoded homology dimensions. \n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\R^{2+d})^n -> \mathbb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After then discussion today, we concluded to approve the PR and merge the NB as is now.
Reference issues/PRs
Types of changes
Description
Screenshots (if appropriate)
Any other comments?
Checklist
flake8
to check my Python changes.pytest
to check this on Python tests.