Skip to main content

A python library focuses on constructing deep probabilistic models on GPU.

Project description

PyDPM

PyPI GitHub Downloads

A python library focuses on constructing deep probabilistic models on GPU. Pydpm provides efficient distribution sampling functions and has included lots of implemented probabilistic models.

Note: We have released a new version that does not depend on Pycuda.

Document

Image text

Install

This library can be installed under both Windows and Linux systems.

$ pip install pydpm

Under Windows system, we recommed to install Visual Studio 2019 and latest CUDA Toolkit. The combination of VS2019(with MSVC v142) and CUDA 11.5 has been tested in pydpm2.0.

Create Probabilistic Model

Model list

Model list is as following:

Probabilistic Model Name Abbreviation Paper Link
Latent Dirichlet Allocation LDA Link
Poisson Factor Analysis PFA Link
Poisson Gamma Belief Network PGBN Link
Convolutional Poisson Factor Analysis CPFA Link
Convolutional Poisson Gamma Belief Network CPGBN Link
Poisson Gamma Dynamical Systems PGDS Link
Deep Poisson Gamma Dynamical Systems DPGDS Link
Dirichlet Belief Networks DirBN Link
Deep Poisson Factor Analysis DPFA Link
Word Embeddings Deep Topic Model WEDTM Link
Multimodal Poisson Gamma Belief Network MPGBN Link
Graph Poisson Gamma Belief Network GPGBN Link

More probabilistic models will be further included in pydpm/_model/...

Demo

Create a PGBN model:

from pydpm.model import PGBN

# create the model and deploy it on gpu or cpu
model = PGBN([128, 64, 32], device='gpu')
model.initial(train_data)
train_local_params = model.train(train_data, iter_all=100)
train_local_params = model.test(train_data, iter_all=100)
test_local_params = model.test(test_data, iter_all=100)

# evaluate the model with classification accuracy
# the demo accuracy can achieve 0.8549
results = ACC(train_local_params.Theta[0], test_local_params.Theta[0], train_label, test_label, 'SVM')

# save the model after training
model.save()

More model demos can be found in pydpm/examples/...

Source data can be found in Link

Sample on GPU

Function list

The parameters of partial distribution functions are as following:

Function Parameters List
Normal mean, std, times
Multinomial count, prob, times
Poisson lambda, times
Gamma shape, scale, times
Beta alpha, beta, times
F n1, n2, times
StudentT n, times
Dirichlet alpha, times
Crt point, p, times
Weibull shape, scale, times
Chisquare n, times
Geometric p, times
... ...

Example

from pydpm._sampler import Basic_Sampler

sampler = Basic_Sampler('gpu')
a = sampler.gamma(np.ones(100)*5, 1, times=10)
b = sampler.gamma(np.ones([100, 100])*5, 1, times=10)

More sampler demos can be found in pydpm/_sampler/...

Compare

Compare the sampling speed of distribution functions with numpy: Image text
The compared code can be found in pydpm/example/Sampler_Speed_Demo.py

Compare the sampling speed of distribution functions with tensorflow and torch: Image text
The compared code can be found in pydpm/example/Sampler_Speed_Demo.py

Contact

License: Apache License Version 2.0

Contact: Chaojie Wang xd_silly@163.com, Wei Zhao 13279389260@163.com, Xinyang Liu lxy771258012@163.com, Jiawen Wu wjw19960807@163.com

Copyright (c), 2020, Chaojie Wang, Wei Zhao, Xinyang Liu, Jiawen Wu, Jie Ren, Yewen Li, Hao Zhang, Bo Chen and Mingyuan Zhou

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydpm-4.0.1.tar.gz (136.6 kB view hashes)

Uploaded Source

Built Distribution

pydpm-4.0.1-py3-none-any.whl (74.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page