64250d0938
Running examples/cli/gmlvq.py crashes with: ``` --------------------------------------------------------------------------- KeyError Traceback (most recent call last) ~/miniconda3/envs/py38/lib/python3.8/site-packages/pytorch_lightning/utilities/parsing.py in __getattr__(self, key) 249 try: --> 250 return self[key] 251 except KeyError as exp: KeyError: 'distribution' The above exception was the direct cause of the following exception: AttributeError Traceback (most recent call last) ~/work/repos/prototorch_models/examples/cli/gmlvq.py in <module> 10 11 ---> 12 cli = LightningCLI(GMLVQMNIST) ~/miniconda3/envs/py38/lib/python3.8/site-packages/pytorch_lightning/utilities/cli.py in __init__(self, model_class, datamodule_class, save_config_callback, trainer_class, trainer_defaults, seed_everything_default, description, env_prefix, env_parse, parser_kwargs, subclass_mode_model, subclass_mode_data) 168 seed_everything(self.config['seed_everything']) 169 self.before_instantiate_classes() --> 170 self.instantiate_classes() 171 self.prepare_fit_kwargs() 172 self.before_fit() ~/miniconda3/envs/py38/lib/python3.8/site-packages/pytorch_lightning/utilities/cli.py in instantiate_classes(self) 211 self.config_init = self.parser.instantiate_subclasses(self.config) 212 self.instantiate_datamodule() --> 213 self.instantiate_model() 214 self.instantiate_trainer() 215 ~/miniconda3/envs/py38/lib/python3.8/site-packages/pytorch_lightning/utilities/cli.py in instantiate_model(self) 228 self.model = self.config_init['model'] 229 else: --> 230 self.model = self.model_class(**self.config_init.get('model', {})) 231 232 def instantiate_trainer(self) -> None: ~/work/repos/prototorch_models/prototorch/models/glvq.py in __init__(self, hparams, **kwargs) 307 def __init__(self, hparams, **kwargs): 308 distance_fn = kwargs.pop("distance_fn", omega_distance) --> 309 super().__init__(hparams, distance_fn=distance_fn, **kwargs) 310 omega = torch.randn(self.hparams.input_dim, 311 self.hparams.latent_dim, ~/work/repos/prototorch_models/prototorch/models/glvq.py in __init__(self, hparams, **kwargs) 39 # Layers 40 self.proto_layer = LabeledComponents( ---> 41 distribution=self.hparams.distribution, 42 initializer=self.prototype_initializer(**kwargs)) 43 ~/miniconda3/envs/py38/lib/python3.8/site-packages/pytorch_lightning/utilities/parsing.py in __getattr__(self, key) 250 return self[key] 251 except KeyError as exp: --> 252 raise AttributeError(f'Missing attribute "{key}"') from exp 253 254 def __setattr__(self, key, val): AttributeError: Missing attribute "distribution" ``` |
||
---|---|---|
docs | ||
examples | ||
prototorch/models | ||
tests | ||
.bumpversion.cfg | ||
.codacy.yml | ||
.codecov.yml | ||
.gitignore | ||
.readthedocs.yml | ||
.travis.yml | ||
LICENSE | ||
README.md | ||
setup.py |
ProtoTorch Models
Pre-packaged prototype-based machine learning models using ProtoTorch and PyTorch-Lightning.
Installation
To install this plugin, simply run the following command:
pip install prototorch_models
The plugin should then be available for use in your Python environment as
prototorch.models
.
Note: Installing the models plugin should automatically install a suitable version of ProtoTorch.
Available models
LVQ Family
- Learning Vector Quantization 1 (LVQ1)
- Generalized Learning Vector Quantization (GLVQ)
- Generalized Relevance Learning Vector Quantization (GRLVQ)
- Generalized Matrix Learning Vector Quantization (GMLVQ)
- Localized and Generalized Matrix Learning Vector Quantization (LGMLVQ)
- Limited-Rank Matrix Learning Vector Quantization (LiRaMLVQ)
- Learning Vector Quantization Multi-Layer Network (LVQMLN)
- Siamese GLVQ
- Cross-Entropy Learning Vector Quantization (CELVQ)
- Robust Soft Learning Vector Quantization (RSLVQ)
Other
- k-Nearest Neighbors (KNN)
- Neural Gas (NG)
- Growing Neural Gas (GNG)
Work in Progress
- Classification-By-Components Network (CBC)
- Learning Vector Quantization 2.1 (LVQ2.1)
Planned models
- Median-LVQ
- Generalized Tangent Learning Vector Quantization (GTLVQ)
- Probabilistic Learning Vector Quantization (PLVQ)
- Self-Incremental Learning Vector Quantization (SILVQ)
Development setup
It is recommended that you use a virtual environment for development. If you do
not use conda
, the easiest way to work with virtual environments is by using
virtualenvwrapper. Once
you've installed it with pip install virtualenvwrapper
, you can do the
following:
export WORKON_HOME=~/pyenvs
mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh # location may vary
mkvirtualenv pt
Once you have a virtual environment setup, you can start install the models
plugin with:
workon pt
git clone git@github.com:si-cim/prototorch_models.git
cd prototorch_models
git checkout dev
pip install -e .[all] # \[all\] if you are using zsh or MacOS
Note: Please avoid installing Tensorflow in this environment.
To assist in the development process, you may also find it useful to install
yapf
, isort
and autoflake
. You can install them easily with pip
.
FAQ
How do I update the plugin?
If you have already cloned and installed prototorch
and the
prototorch_models
plugin with the -e
flag via pip
, all you have to do is
navigate to those folders from your terminal and do git pull
to update.