Skip to content
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

Merged
merged 9 commits into from
Jul 13, 2022
Merged

Notebook orbit5k #99

merged 9 commits into from
Jul 13, 2022

Conversation

nberkouk
Copy link
Collaborator

Reference issues/PRs

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Screenshots (if appropriate)

Any other comments?

Checklist

  • I have read the guidelines for contributing.
  • My code follows the code style of this project. I used flake8 to check my Python changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed. I used pytest to check this on Python tests.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

Copy link
Collaborator

@raphaelreinauer raphaelreinauer left a 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.

@raphaelreinauer raphaelreinauer self-requested a review July 13, 2022 13:20
Copy link
Collaborator

@raphaelreinauer raphaelreinauer left a 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.

"\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",
Copy link
Collaborator

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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"\n",
"import torch\n",
"import torch.nn as nn\n",
"\n",
"# Gdeep imports \n",
"\n",
"from gdeep.data import PreprocessingPipeline\n",
Copy link
Collaborator

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.

" num_attention_layers=2,\n",
" num_attention_heads=8,\n",
")\n",
"\n",
"wrapped_model = PersformerWrapper(\n",
Copy link
Collaborator

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

Copy link
Collaborator

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

@@ -121,6 +184,15 @@
"source": [
"# Define the model by using a Wrapper for the Persformer model\n",
"\n",
"model_config = PersformerConfig(\n",
Copy link
Collaborator

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",
Copy link
Collaborator

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",
Copy link
Collaborator

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",
Copy link
Collaborator

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

Copy link
Contributor

@matteocao matteocao left a 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.

@matteocao matteocao merged commit 61ca3cc into master Jul 13, 2022
@matteocao matteocao deleted the notebook_orbit5k branch July 13, 2022 16:16
@matteocao matteocao linked an issue Jul 13, 2022 that may be closed by this pull request
@matteocao matteocao mentioned this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notebook on Orbit5k
4 participants