Skip to content

Commit

Permalink
Merge pull request #116 from raphaelreinauer/master
Browse files Browse the repository at this point in the history
Updated outdated docstring of FFNet and fixed types
  • Loading branch information
matteocao authored Sep 30, 2022
2 parents c1922da + 81c54b0 commit 89a0944
Show file tree
Hide file tree
Showing 76 changed files with 217 additions and 205 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ hyperparameter optimization in a few lines of code.

You can find the documentation of this repository here: https://giotto-ai.github.io/giotto-deep/

## Run tensorboard for visualisation
## Run tensorboard for visualization

In order to analyse the results of your models, you need to start **tensorboard**. On the terminal, move inside the `/examples` folder. There, run the following command:
```
tensorboard --logdir=runs
```
Afterwards go [here](http://localhost:6006/) and, after running the notebooks of interest, you will see all the visualisation results that you stored in the `writer = SummaryWriter()`.
Afterwards go [here](http://localhost:6006/) and, after running the notebooks of interest, you will see all the visualization results that you stored in the `writer = SummaryWriter()`.

## Install user version

Expand Down
2 changes: 1 addition & 1 deletion docs/source/modules/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This pages contains a list of available features in the library.

utility

visualisation
visualization

References
----------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/modules/visualisation.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Visualisation
visualization
============

.. automodule:: gdeep.visualisation
.. automodule:: gdeep.visualization
:members:
4 changes: 2 additions & 2 deletions examples/basic_tutorial_ensemble_learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"from gdeep.utility.optimization import SAMOptimizer\n",
"from gdeep.models import FFNet\n",
"from gdeep.utility import ensemble_wrapper\n",
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"from gdeep.search import GiottoSummaryWriter\n"
]
},
Expand All @@ -58,7 +58,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training to see all the visualisation results."
"Then go [here](http://localhost:6006/) after the training to see all the visualization results."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/basic_tutorial_hpo_and_benchmarking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"from gdeep.search import Benchmark\n",
"from gdeep.search import HyperParameterOptimization, GiottoSummaryWriter\n",
"from gdeep.models import FFNet\n",
"from gdeep.visualisation import persistence_diagrams_of_activations\n"
"from gdeep.visualization import persistence_diagrams_of_activations\n"
]
},
{
Expand All @@ -70,7 +70,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training to see all the visualisation results.\n",
"Then go [here](http://localhost:6006/) after the training to see all the visualization results.\n",
"\n",
"In this example, we use our modified version of the writer, as we believe it displays better results in the `hparams` dashboard."
]
Expand Down
8 changes: 4 additions & 4 deletions examples/basic_tutorial_image.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
"\n",
"from gdeep.data.datasets import DatasetBuilder, DataLoaderBuilder\n",
"from gdeep.models import FFNet\n",
"from gdeep.visualisation import persistence_diagrams_of_activations\n",
"from gdeep.visualization import persistence_diagrams_of_activations\n",
"from gdeep.data.preprocessors import ToTensorImage\n",
"from gdeep.trainer import Trainer\n",
"from gdeep.models import ModelExtractor\n",
"from gdeep.analysis.interpretability import Interpreter\n",
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"from gdeep.search import GiottoSummaryWriter"
]
},
Expand All @@ -67,7 +67,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training of your model to see all the visualisation results."
"Then go [here](http://localhost:6006/) after the training of your model to see all the visualization results."
]
},
{
Expand Down Expand Up @@ -309,7 +309,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interactive 3d visualisation\n",
"## Interactive 3d visualization\n",
"\n",
"You can visualise the dataset in 3D (choosing dynamically the dimensionality reduction algorithm) the dataset on tehsnorboard. In order to do so, just run teh next cell!"
]
Expand Down
8 changes: 4 additions & 4 deletions examples/basic_tutorial_question_answering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"from torch.utils.data.sampler import SubsetRandomSampler\n",
"\n",
"from gdeep.models import FFNet\n",
"from gdeep.visualisation import persistence_diagrams_of_activations\n",
"from gdeep.visualization import persistence_diagrams_of_activations\n",
"from gdeep.data.datasets import DatasetBuilder\n",
"from gdeep.trainer import Trainer\n",
"from gdeep.models import ModelExtractor\n",
Expand All @@ -55,7 +55,7 @@
"from gdeep.data import TransformingDataset\n",
"from gdeep.data.preprocessors import Normalization, TokenizerQA\n",
"from gdeep.data.datasets import DataLoaderBuilder\n",
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"from gdeep.search import GiottoSummaryWriter\n"
]
},
Expand All @@ -72,7 +72,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training to see all the visualisation results."
"Then go [here](http://localhost:6006/) after the training to see all the visualization results."
]
},
{
Expand Down Expand Up @@ -464,7 +464,7 @@
"metadata": {},
"outputs": [],
"source": [
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"\n",
"vs = Visualiser(pipe)\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/basic_tutorial_regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"\n",
"from gdeep.search import GiottoSummaryWriter\n",
"from gdeep.models import FFNet\n",
"from gdeep.visualisation import persistence_diagrams_of_activations\n",
"from gdeep.visualization import persistence_diagrams_of_activations\n",
"from gdeep.trainer import Trainer\n",
"from gdeep.data.datasets import DatasetBuilder, FromArray, DataLoaderBuilder\n",
"from gdeep.utility import DEVICE\n"
Expand All @@ -69,7 +69,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/), after the training phase, to see all the visualisation results."
"Then go [here](http://localhost:6006/), after the training phase, to see all the visualization results."
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/basic_tutorial_tabular.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"from gdeep.models import ModelExtractor\n",
"from gdeep.analysis.interpretability import Interpreter\n",
"from gdeep.utility.optimization import SAMOptimizer\n",
"from gdeep.visualisation import persistence_diagrams_of_activations\n",
"from gdeep.visualization import persistence_diagrams_of_activations\n",
"from gdeep.trainer import Trainer\n",
"from gdeep.data.datasets import DatasetBuilder, DataLoaderBuilder\n",
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"from gdeep.utility import DEVICE\n",
"from gdeep.search import GiottoSummaryWriter"
]
Expand All @@ -70,7 +70,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training pahse to see all the visualisation results."
"Then go [here](http://localhost:6006/) after the training pahse to see all the visualization results."
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/basic_tutorial_text_classification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
"from torchvision import transforms\n",
"\n",
"from gdeep.models import FFNet\n",
"from gdeep.visualisation import persistence_diagrams_of_activations\n",
"from gdeep.visualization import persistence_diagrams_of_activations\n",
"from gdeep.data.datasets import DatasetBuilder\n",
"from gdeep.data import PreprocessingPipeline\n",
"from gdeep.data import TransformingDataset\n",
"from gdeep.data.preprocessors import Normalization, TokenizerTextClassification\n",
"from gdeep.data.datasets import DataLoaderBuilder\n",
"from gdeep.trainer import Trainer\n",
"from gdeep.analysis.interpretability import Interpreter\n",
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"from gdeep.models import ModelExtractor\n",
"from gdeep.search import GiottoSummaryWriter\n"
]
Expand All @@ -73,7 +73,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training to see all the visualisation results."
"Then go [here](http://localhost:6006/) after the training to see all the visualization results."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/basic_tutorial_translation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@
"\n",
"# our special guests!\n",
"from gdeep.models import FFNet\n",
"from gdeep.visualisation import persistence_diagrams_of_activations\n",
"from gdeep.visualization import persistence_diagrams_of_activations\n",
"from gdeep.data.datasets import DatasetBuilder\n",
"from gdeep.trainer import Trainer\n",
"from gdeep.data import TransformingDataset\n",
"from gdeep.data.preprocessors import TokenizerTranslation\n",
"from gdeep.data.datasets import DataLoaderBuilder\n",
"from gdeep.models import ModelExtractor\n",
"from gdeep.analysis.interpretability import Interpreter\n",
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"from gdeep.search import GiottoSummaryWriter\n"
]
},
Expand Down
4 changes: 2 additions & 2 deletions examples/compactification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training of your model to see all the visualisation results."
"Then go [here](http://localhost:6006/) after the training of your model to see all the visualization results."
]
},
{
Expand Down Expand Up @@ -153,7 +153,7 @@
"metadata": {},
"outputs": [],
"source": [
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"\n",
"vs = Visualiser(pipe)\n",
"vs.plot_interactive_model() # send to tensorboard the interactive model of FFNet\n",
Expand Down
6 changes: 3 additions & 3 deletions examples/decision_boundary_tori.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training of your model to see all the visualisation results."
"Then go [here](http://localhost:6006/) after the training of your model to see all the visualization results."
]
},
{
Expand Down Expand Up @@ -134,7 +134,7 @@
"source": [
"## Visualising the decision boundary\n",
"\n",
"We are sending to the tensorboard the visualisation data: hence, you can explore the different sections to find the different plots there. Note that the interactive 3D decison boundary can be found in the **projector** section."
"We are sending to the tensorboard the visualization data: hence, you can explore the different sections to find the different plots there. Note that the interactive 3D decison boundary can be found in the **projector** section."
]
},
{
Expand All @@ -143,7 +143,7 @@
"metadata": {},
"outputs": [],
"source": [
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"\n",
"vs = Visualiser(pipe)\n",
"vs.plot_interactive_model()\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/orbit_5k_pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"from sklearn.model_selection import train_test_split\n",
"from torch.optim import Adam\n",
"from torch.utils.data import Subset\n",
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"from gdeep.data.datasets import OrbitsGenerator, DataLoaderKwargs\n",
"\n",
"\n",
Expand Down Expand Up @@ -221,7 +221,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training to see all the visualisation results.\n"
"Then go [here](http://localhost:6006/) after the training to see all the visualization results.\n"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/time_series_persformer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"from gdeep.trainer.trainer import Trainer\n",
"from gdeep.utility.utils import autoreload_if_notebook\n",
"from gdeep.analysis.interpretability import Interpreter\n",
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"\n",
"\n",
"autoreload_if_notebook()\n"
Expand Down
6 changes: 3 additions & 3 deletions examples/topo_deep_neural_networks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"# gdeep\n",
"from gdeep.data.datasets import DatasetBuilder, DataLoaderBuilder\n",
"from gdeep.models import FFNet\n",
"from gdeep.visualisation import persistence_diagrams_of_activations\n",
"from gdeep.visualization import persistence_diagrams_of_activations\n",
"from gdeep.data.preprocessors import ToTensorImage\n",
"from gdeep.trainer import Trainer\n",
"from gdeep.search import Benchmark\n",
Expand Down Expand Up @@ -85,7 +85,7 @@
"tensorboard --logdir=runs\n",
"```\n",
"\n",
"Then go [here](http://localhost:6006/) after the training to see all the visualisation results.\n"
"Then go [here](http://localhost:6006/) after the training to see all the visualization results.\n"
]
},
{
Expand Down Expand Up @@ -204,7 +204,7 @@
"metadata": {},
"outputs": [],
"source": [
"from gdeep.visualisation import Visualiser\n",
"from gdeep.visualization import Visualiser\n",
"\n",
"# Choose the size of the subset of the dataset\n",
"batch_size = 500\n",
Expand Down
4 changes: 2 additions & 2 deletions gdeep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
search,
topology_layers,
utility,
visualisation,
visualization,
)

__all__ = [
Expand All @@ -20,5 +20,5 @@
"search",
"topology_layers",
"utility",
"visualisation",
"visualization",
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def test_gfdbc_2_dim():

circle_detect_nn = FFNet([2, 2]).to(DEVICE)
circle_detect_nn = FFNet((2, 2)).to(DEVICE)

g = GradientFlowDecisionBoundaryCalculator(
model=circle_detect_nn,
Expand All @@ -24,7 +24,7 @@ def test_gfdbc_2_dim():

def test_gfdbc_multiclass():

circle_nn_3d = FFNet([3, 3]).to(DEVICE)
circle_nn_3d = FFNet((3, 3)).to(DEVICE)

g = GradientFlowDecisionBoundaryCalculator(
model=circle_nn_3d,
Expand Down
6 changes: 3 additions & 3 deletions gdeep/analysis/interpretability/captum.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from gdeep.utility import DEVICE

from gdeep.utility.custome_types import Tensor
from gdeep.utility.custom_types import Tensor


class Interpreter:
Expand Down Expand Up @@ -38,7 +38,7 @@ def __init__(self, model: nn.Module, method: str = "IntegratedGradients"):
# self.model = model
self.model = model.to(DEVICE)
self.method = method
self.stored_visualisations: List = []
self.stored_visualizations: List = []

def interpret(
self,
Expand Down Expand Up @@ -209,7 +209,7 @@ def interpret_text(
pred_ind,
label,
delta.item(),
self.stored_visualisations,
self.stored_visualizations,
)
return sentence, self.attribution

Expand Down
2 changes: 1 addition & 1 deletion gdeep/analysis/interpretability/tests/test_captum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from gdeep.data.datasets import DatasetBuilder
from gdeep.analysis.interpretability import Interpreter
from gdeep.visualisation import Visualiser
from gdeep.visualization import Visualiser
from gdeep.data import PreprocessingPipeline
from gdeep.data import TransformingDataset
from gdeep.data.preprocessors import Normalization, TokenizerTextClassification
Expand Down
Loading

0 comments on commit 89a0944

Please sign in to comment.