Package: np-family
Neural Process FamilyThis library is in the early stages of development.PyTorch versions are not yet supported.InstallationYou can choose between the following installation methods:NPF as a library# From PyPI (recommended)pipinstallnp-family# Latest version (from current branch; dev-v4)pipinstallgit+https://github.com/yuneg11/Neural-Process-Family@dev-v4# Specific release (from tag; 0.0.1.dev0)pipinstallgit+https://github.com/yuneg11/Neural-Process-Family@0.0.1.dev0Then, you can use the library as follows:fromnpf.jax.modelsimportCNPcnp=CNP(y_dim=1)You should handle other logics (include train, evaluation, etc...)NPF as an experiment framework# Dependenciespipinstallrichnxcl==0.0.3.dev3## And ML frameworks (JAX, PyTorch)# ex) pip install jax# Clone the repositorygitclonehttps://github.com/yuneg11/Neural-Process-FamilynpfcdnpfThen, you can run the experiment, for example:pythonscripts/jax/train.py-fconfigs/gp/rbf/inf/anp.yaml-lr0.0001--model.train_kwargs.num_latents30The output will be saved underouts/directory.
Details will be added in the future.Download or build datasetspython-mnpf.jax.data.save\--root<dataset-root>\--dataset<dataset-name><dataset-root>: The root path to save dataset. Default:./datasets/<dataset-name>: The name of the dataset to save. See below sections for available datasets.Image datasetsYou should installtorchandtorchvisionto download the datastes.
You can find the details in thedownload page.For example,# CUDA 11.3condainstallpytorchtorchvisioncudatoolkit=11.3-cpytorchAvailable datasetsMNIST:mnistCIFAR10:cifar10CIFAR100:cifar100CelebA:celebaSVHN:svhnSim2Real datasetsYou should installnumbaandwgetto simulate or download the datasets.pipinstallnumbawgetAvailable datasetsLotka Volterra:lotka_volterraTODO: Seenpf.jax.data.save:save_lotka_volterrafor more detailed options.ModelsCNP: Conditional Neural ProcessNP: Neural ProcessCANP: Conditional Attentive Neural ProcessANP: Attentive Neural ProcessBNP: Bootstrapping Neural ProcessBANP: Bootstrapping Attentive Neural ProcessNeuBNP: Neural Bootstrapping Neural ProcessNeuBANP: Neural Bootstrapping Attentive Neural ProcessConvCNP: Convolutional Conditional Neural ProcessConvNP: Convolutional Neural ProcessScriptsTrainpythonscripts/jax/train.py-f<config-file>[additional-options]You can use your own config file or use the provided config files in theconfigsdirectory.
For example, the following command will train a CNP model with learning rate of0.0001for100epochs:pythonscripts/jax/train.py-fconfigs/gp/rbf/inf/anp.yaml\-lr0.0001\--train.num_epochs100You can see the help of the config file by using the following command:pythonscripts/jax/train.py-f<config-file>--helpTest# From a trained model directorypythonscripts/jax/test.py-d<model-output-dir>[additional-options]# From a new config file and a trained model checkpointpythonscripts/jax/test.py-f<config-file>-c<checkpoint-file-path>[additional-options]You can directly test the trained model by specifying the output directory.
For example:pythonscripts/jax/test.py-douts/CNP/Train/RBF/Inf/220704-181313-vwehwhereouts/CNP/Train/RBF/Inf/220704-181313-vwehis the output directory of the trained model.You can also replace or add the test-specific configs from the config file using the-tf / --test-config-fileoption.
For example:pythonscripts/jax/test.py-douts/CNP/Train/RBF/Inf/220704-181313-vweh\-tfconfigs/gp/robust/matern.yamlTest Bayesian optimization# From a trained model directorypythonscripts/jax/test_bo.py-d<model-output-dir>[additional-options]# From a new config file and a trained model checkpointpythonscripts/jax/test_bo.py-f<config-file>-c<checkpoint-file-path>[additional-options]Similar to above thetestscript, you can directly test the trained model by specifying the output directory.
For example:pythonscripts/jax/test_bo.py-douts/CNP/Train/RBF/Inf/220704-181313-vwehYou can also replace or add the test-specific configs from the config file using the-bf / --bo-config-fileoption.
For example:pythonscripts/jax/test.py-douts/CNP/Train/RBF/Inf/220704-181313-vweh\-bfconfigs/gp/rbf/bo_config.yamlAppendixDatasets1D regression (x:[B, P, 1],y:[B, P, 1],mask:[B, P])Gaussian processes, etc...2D Image (x:[B, P, P, 2],y:[B, P, P, (1 or 3)],mask:[B, P, P])Image completion, super resolution, etc...Bayesian optimization (x:[B, P, D],y:[B, P, 1],mask:[B, P])Dimension rulex:[batch, *data_specific_dims, data_dim]y:[batch, *data_specific_dims, data_dim]mask:[batch, *data_specific_dims]outs:[batch, *model_specific_dims, *data_specific_dims, data_dim]ExamplesAtCNP1D regression:x:[batch, point, 1]y:[batch, point, 1]mask:[batch, point]outs:[batch, point, 1]AtNP1D regression:x:[batch, point, 1]y:[batch, point, 1]mask:[batch, point]outs:[batch, latent, point, 1]AtCNP2D image regression:x:[batch, height, width, 2]y:[batch, height, width, 1 or 3]mask:[batch, height, width]outs:[batch, height, width, 1 or 3]AtNP2D image regression:x:[batch, height, width, 2]y:[batch, height, width, 1 or 3]mask:[batch, height, width]outs:[batch, latent, height, width, 1 or 3]AtBNP1D regression:x:[batch, point, 1]y:[batch, point, 1]mask:[batch, point]outs:[batch, sample, point, 1]AtBNP2D image regression:x:[batch, height, width, 2]y:[batch, height, width, 1 or 3]mask:[batch, height, width]outs:[batch, sample, height, width, 1 or 3]