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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file pydpm-4.0.1.tar.gz.

File metadata

  • Download URL: pydpm-4.0.1.tar.gz
  • Upload date:
  • Size: 136.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for pydpm-4.0.1.tar.gz
Algorithm Hash digest
SHA256 f39fb4fbdd38c414fc7e7801dbb5cc84bd9b75f56ae49e3e0e069d3b7e1c8055
MD5 66e9ad8149a77ab0edbd21ae49b9eb19
BLAKE2b-256 6dd9457d0cbf7e494e84a26c8b4c2554013ef3843eb2c18844aedc6d864145bc

See more details on using hashes here.

File details

Details for the file pydpm-4.0.1-py3-none-any.whl.

File metadata

  • Download URL: pydpm-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 74.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for pydpm-4.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9fa7e55f2af38e09b7e854060ee0cb41984bd2f926d930bd75956371808a854
MD5 0fdf9e017903709786312e2fc077551c
BLAKE2b-256 69a461d92bf50cc2fd95e843b80a68e0796affb7516bc6824ed26fcd9d71e393

See more details on using hashes here.

Supported by

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