Skip to content

Commit 9ecbd77

Browse files
author
J. Cappelletto
committed
Update README with detailed installation information and help summary
1 parent 77c8a1d commit 9ecbd77

1 file changed

Lines changed: 107 additions & 9 deletions

File tree

README.md

Lines changed: 107 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,118 @@ A ML framework to infer high resolution terrain properties (e.g. slope, rugosity
55
sensed low resolution maps. A Bayesian neural network [https://github.com/piEsposito/blitz-bayesian-deep-learning/] is used to model the relationship between a compact representation of the terrain and the target output. Unsupervised terrain feature extraction is done via Location Guided Autoencoder [https://github.com/ocean-perception/location_guided_autoencoder] or by using contrastive learning (GeoCLR).
66

77
# Requirements
8-
System requeriments for a typ. small network (5 layers, 256 nodes per layer max)
9-
* CUDA 10+ capable GPU
8+
Current implementation uses a small fully connected neural network (5 layers, 256 nodes per layer max). The GPU memory footprint is ~500MB so multiple train/predict instances can be dispatched. The minimum required system is
9+
10+
* GPU card with >1 GB
11+
* CUDA 10+
1012
* 8 GB of RAM
1113
* 2C/4T CPU
1214

13-
For replicability purposes, conda is used to manage the environment setup with all the dependencies.
14-
1515
# Installation
16-
TODO: Complete detailed description:
17-
* Point to env.yaml
18-
* Refer to conda env creation from file
19-
* Install blitz from conda channel
20-
* Done
16+
Start by cloning the repository (it will include the blitz submodule):
17+
18+
```
19+
$ git clone https://github.com/cappelletto/bayesian-inference.git
20+
```
21+
22+
## Conda environment
23+
For improved stability and compatibility, using virtual environment (venv) or conda is recommended. You can create a new conda environment with:
24+
25+
```
26+
$ conda create --name bnninference python=3.10
27+
```
28+
29+
Once created, activate it using:
30+
31+
```
32+
$ conda activate bnninference
33+
```
34+
35+
## Dependencies
36+
37+
Now we can proceed to install the general dependencies listed in the requirements file:
38+
39+
```
40+
$ pip install -r environment/requirements.txt
41+
```
42+
43+
And then install the blitz submodule
44+
```
45+
$ cd bnn_inference/submodules/blitz/
46+
$ python setup.py install
47+
```
48+
49+
## Bayesian predictor
50+
Finally, we can install the *bayesian-predictor* package via pip as [^1]:
51+
```
52+
$ cd ../..
53+
$ python setupy. build
54+
$ pip install .
55+
```
2156

2257
# Usage
58+
The current implementation is separated into two modules, one for training and another one for predictions. Both use the same sintaxis to define inputs, outputs, training/inference parameters, etc. For a complete list of all the available features and flags please run any of the modules with the ` --help ` flag
59+
60+
For the training module:
61+
```
2362
bnn_train.py --help
63+
```
64+
It will return something similar to:
65+
66+
```
67+
INFO > Bayesian NN training module: learning hi-res terrain observations from feature representation of low resolution priors
68+
usage: bnn_train [-h] [-i INPUT] [-l LATENT] [-t TARGET] [-k KEY] [-o OUTPUT] [-u UUID] [-n NETWORK] [-g LOGFILE]
69+
[-c CONFIG] [-e EPOCHS] [-s SAMPLES] [-x XRATIO] [--scale SCALE] [--lr LR]
70+
[--lambda_recon LAMBDA_RECON] [--lambda_elbo LAMBDA_ELBO] [--gpu GPU] [--uncertainty]
71+
72+
Bayesian Neural Network training module
73+
74+
options:
75+
-h, --help show this help message and exit
76+
-i INPUT, --input INPUT
77+
Path to CSV containing the latent representation vector for each input entry (image). The 'UUID'
78+
is used to match against the target file entries
79+
-l LATENT, --latent LATENT
80+
Name of the key used for the columns containing the latent vector. For example, a h=8 vector
81+
should be read as 'latent_0,latent_1,...,latent_7'
82+
-t TARGET, --target TARGET
83+
Path to CSV containing the target entries to be used for training/validation. The 'UUID' is used
84+
to match against the input file entries
85+
-k KEY, --key KEY Keyword that defines the field to be learnt/predicted. It must match the column name in the
86+
target file
87+
-o OUTPUT, --output OUTPUT
88+
File containing the expected and inferred value for each input entry. It preserves the input
89+
file columns and appends the corresponding prediction
90+
-u UUID, --uuid UUID Unique identifier string used as key for input/target example matching. The UUID string must
91+
match for both the input (latent) file and the target file column identifier
92+
-n NETWORK, --network NETWORK
93+
Output path to write the trained Bayesian Neural Network in PyTorch compatible format.
94+
-g LOGFILE, --logfile LOGFILE
95+
Output path to the logfile with the training / validation error for each epoch. Used to inspect
96+
the training performance
97+
-c CONFIG, --config CONFIG
98+
Path to YAML configuration file (optional)
99+
-e EPOCHS, --epochs EPOCHS
100+
Define the number of training epochs
101+
-s SAMPLES, --samples SAMPLES
102+
Define the number of samples for sample_elbo based posterior estimation
103+
-x XRATIO, --xratio XRATIO
104+
Define the training (T) ratio as the proportion of the complete dataset used for training. T + V
105+
= 1.0
106+
--scale SCALE Define the output target scaling factor. Default: 1.0 (no scaling))
107+
--lr LR Define the learning rate for the optimizer. Default: 0.001
108+
--lambda_recon LAMBDA_RECON
109+
Define the lambda value for the reconstruction loss. Default: 10.0
110+
--lambda_elbo LAMBDA_ELBO
111+
Define the lambda value for the ELBO KL divergence cost. Default: 1.0
112+
--gpu GPU Index of CUDA device to be used. Default: 0
113+
--uncertainty Add flag to export uncertainty in the output file
114+
```
115+
116+
117+
```
24118
bnn_predict.py --help
119+
```
120+
121+
122+
[^1]: Verify you are back in the root folder of this repository

0 commit comments

Comments
 (0)