Giter VIP home page Giter VIP logo

pydpm's Introduction

Pydpm

PyPI GitHub

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.

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

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(100, train_data)
train_local_params = model.test(100, train_data)
test_local_params = model.test(100, test_data)

# 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/Sample_Demo.py

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

Contact

License: Apache License Version 2.0

Contact: Chaojie Wang [email protected], Wei Zhao [email protected], Jiawen Wu [email protected]

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

pydpm's People

Contributors

bochengroup avatar chaojiewang94 avatar dustone-mu avatar xd-wjw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.