
This is the documentation of trixi (Training & Retrospective Insights eXperiment Infrastructure). trixi is a python package aiming to facilitate the setup, visualization and comparison of reproducible experiments, currently with a focus on experiments using PyTorch.
You can jump right into the package by looking into our Quick Start.
Installation¶
Install Trixi:
pip install trixiInstall trixi directly via git:
git clone https://github.com/MIC-DKFZ/trixi.git cd trixi pip install -e .
Quick Start¶
Introduction & Features:
https://github.com/MIC-DKFZ/trixi#features
Install trixi:
pip install trixi
Have a look and run a simple MNIST example:
https://github.com/MIC-DKFZ/trixi/blob/master/examples/pytorch_experiment.ipynb
License¶
The MIT License (MIT)
Copyright (c) 2018 Medical Image Computing Group, DKFZ
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Authors¶
Core Development Team:
- David Zimmerer (d.zimmerer@dkfz.de)
- Jens Petersen (jens.petersen@dkfz.de)
- Gregor Koehler (g.koehler@dkfz.de)
Contributions:
- Jakob Wasserthal
- Sebastian Wirkert
- Lisa Kausch
trixi.experiment¶
Experiment¶
-
class
trixi.experiment.experiment.
Experiment
(n_epochs=0)[source]¶ Bases:
object
An abstract Experiment which can be run for a number of epochs.
The basic life cycle of an experiment is:
setup() prepare() while epoch < n_epochs: train() validate() epoch += 1 end()
If you want to use another criterion than number of epochs, e.g. stopping based on validation loss, you can implement that in your validation method and just call .stop() at some point to break the loop. Just set your n_epochs to a high number or np.inf.
The reason there is both
setup()
andprepare()
is that internally there is also a_setup_internal()
method for hidden magic in classes that inherit from this. For example, thetrixi.experiment.pytorchexperiment.PytorchExperiment
uses this to restore checkpoints. Think ofsetup()
as an__init__()
that is only called when the Experiment is actually asked to do anything. Then useprepare()
to modify the fully instantiated Experiment if you need to.To write a new Experiment simply inherit the Experiment class and overwrite the methods. You can then start your Experiment calling
run()
In Addition the Experiment also has a test function. If you call the
run_test()
method it will call thetest()
andend_test()
method internally (and if you give the parameter setup = True in run_test is will again callsetup()
andprepare()
).Each Experiment also has its current state in
_exp_state
, its start time in_time_start
, its end time in_time_end
and the current epoch index in_epoch_idx
Parameters: n_epochs (int) – The number of epochs in the Experiment (how often the train and validate method will be called) -
epoch
¶ Convenience access property for self._epoch_idx
-
process_err
(e)[source]¶ This method is called if an error occurs during the execution of an experiment. Will just raise by default.
Parameters: e (Exception) – The exception which was raised during the experiment life cycle
-
run
(setup=True)[source]¶ This method runs the Experiment. It runs through the basic lifecycle of an Experiment:
setup() prepare() while epoch < n_epochs: train() validate() epoch += 1 end()
-
run_test
(setup=True)[source]¶ This method runs the Experiment.
The test consist of an optional setup and then calls the
test()
andend_test()
.Parameters: setup – If True it will execute the setup()
andprepare()
function similar to the run method before callingtest()
.
-
setup
()[source]¶ Is called at the beginning of each Experiment run to setup the basic components needed for a run.
-
PytorchExperiment¶
trixi.logger¶
AbstractLogger¶
-
class
trixi.logger.abstractlogger.
AbstractLogger
(*args, **kwargs)[source]¶ Bases:
object
Abstract interface for visual logger.
-
process_params
(f, *args, **kwargs)[source]¶ Implement this to handle data conversions in your logger.
Example: Implement logger for numpy data, then implement torch logger as child of numpy logger and just use the process_params method to convert from torch to numpy.
-
show_barplot
(*args, **kwargs)[source]¶ Abstract method which should handle and somehow log/ store a barplot
-
show_image
(*args, **kwargs)[source]¶ Abstract method which should handle and somehow log/ store an image
-
show_lineplot
(*args, **kwargs)[source]¶ Abstract method which should handle and somehow log/ store a lineplot
-
show_piechart
(*args, **kwargs)[source]¶ Abstract method which should handle and somehow log/ store a piechart
-
show_scatterplot
(*args, **kwargs)[source]¶ Abstract method which should handle and somehow log/ store a scatterplot
-