API Reference#

vulkpy Package#

vulkpy: GPGPU array on Vulkan#

vulkpy provides GPGPU computations.

See also

vulkpy.random

Random Module

vulkpy.nn

Neural Network Module

vulkpy.util

Utility Module

Examples

>>> import vulkpy as vk
>>> gpu = vk.GPU()
>>> a = vk.Array(gpu, data=[1, 2, 3])
>>> b = vk.Array(gpu, data=[3, 3, 3])
>>> c = a + b
>>> print(c)
[4., 5., 6.]

Functions#

zeros(gpu, shape)

Zero initialized Array

Classes#

Array

GPU Array for float (32bit)

GPU

GPU instance

Shape

GPU Array of uint (32bit) for shape

U32Array

GPU Array of uint (32bit) for shape or indices

Class Inheritance Diagram#

Inheritance diagram of vulkpy.vkarray.Array, vulkpy.vkarray.GPU, vulkpy.vkarray.Shape, vulkpy.vkarray.U32Array

vulkpy.random Module#

Random Module (vulkpy.random)#

GPU-based Pseudo Random Number Generator (PRNG)

Examples

>>> import vulkpy as vk
>>> gpu = vk.GPU()
>>> r = vk.random.Xoshiro128pp(gpu, seed=0)

[0, 1) uniform random numbers can be generated by random(shape=None, buffer=None).

>>> print(r.random(shape=(3,)))
[0.42977667 0.8235899  0.90622926]

Gaussian random numbers can be generated by normal(shape=None, buffer=None, mean=0.0, stddev=1.0).

>>> print(r.normal(shape=(3,)))
[-2.3403292  0.7247794  0.7118352]

Classes#

Xoshiro128pp

xoshiro128++: Pseudo Random Number Generator

Class Inheritance Diagram#

Inheritance diagram of vulkpy.random.Xoshiro128pp

vulkpy.nn Package#

Neural Network Module (vulkpy.nn)#

Examples

>>> import vulkpy as vk
>>> from vulkpy import nn
>>> gpu = vk.GPU()
>>> x = vk.Array(gpu, data=[ ... ]) # Features
>>> y = vk.Array(gpu, data=[ ... ]) # Labels

Create Optimizer and Model

>>> opt = nn.Adam(gpu, lr=1e-4)
>>> net = nn.Sequence(
...   [
...     nn.Dense(gpu, 3, 32, w_opt=opt, b_opt=opt),
...     nn.ReLU(),
...     nn.Dense(gpu, 32, 4, w_opt=opt, b_opt=opt),
...     nn.Softmax(),
...   ],
...   nn.CrossEntropy()
... )

Training Model

>>> pred_y, loss = net.train(x, y)

Predict with Model

>>> pred_y = net.predict(x)

Classes#

AdaGrad

AdaGrad Optimizer

AdaGradState

Optimizer State for AdaGrad

Adam

Adam Optimizer

AdamState

Optimizer State for Adam

Constant

Constant Initializer

CrossEntropyLoss

Cross Entropy Loss

Dense

Fully connected Dense Layer

Elastic

Elastic (L1 + L2) Regularization

HeNormal

He Normal Initializer

HuberLoss

Huber Loss

Lasso

Lasso (L1) Regularization

Loss

Abstract base class for Loss

MSELoss

Mean Squared Loss

Module

Abstract base class for Module

Optimizer

Abstract base class for Optimizer

OptimizerState

Abstract base class for Optimizer State

ReLU

Rectified Linear Unit (ReLU)

Regularizer

Abstract base class for Regularizer

Ridge

Ridge (L2) Regularization

SGD

SGD Optimizer

SGDState

Optimizer State for SGD

Sequence

Sequential Model

Sigmoid

Sigmoid

Softmax

SoftMax

SoftmaxCrossEntropyLoss

Softmax Cross Entropy Loss

Class Inheritance Diagram#

Inheritance diagram of vulkpy.nn.optimizers.AdaGrad, vulkpy.nn.optimizers.AdaGradState, vulkpy.nn.optimizers.Adam, vulkpy.nn.optimizers.AdamState, vulkpy.nn.initializers.Constant, vulkpy.nn.losses.CrossEntropyLoss, vulkpy.nn.layers.Dense, vulkpy.nn.regularizers.Elastic, vulkpy.nn.initializers.HeNormal, vulkpy.nn.losses.HuberLoss, vulkpy.nn.regularizers.Lasso, vulkpy.nn.core.Loss, vulkpy.nn.losses.MSELoss, vulkpy.nn.core.Module, vulkpy.nn.core.Optimizer, vulkpy.nn.core.OptimizerState, vulkpy.nn.layers.ReLU, vulkpy.nn.core.Regularizer, vulkpy.nn.regularizers.Ridge, vulkpy.nn.optimizers.SGD, vulkpy.nn.optimizers.SGDState, vulkpy.nn.models.Sequence, vulkpy.nn.layers.Sigmoid, vulkpy.nn.layers.Softmax, vulkpy.nn.losses.SoftmaxCrossEntropyLoss

vulkpy.util Module#

Utility Module (vulkpy.util)#

Examples

>>> from vulkpy.util import enable_debug
>>> enable_debug(api_dump=False)

Functions#

enable_debug(*[, validation, api_dump])

Enable debug message

getShader(name)

Get Shader Path