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#
|
Zero initialized Array |
Classes#
Class Inheritance Diagram#
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#
xoshiro128++: Pseudo Random Number Generator |
Class Inheritance Diagram#
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 Optimizer |
|
Optimizer State for AdaGrad |
|
Adam Optimizer |
|
Optimizer State for Adam |
|
Constant Initializer |
|
Cross Entropy Loss |
|
Fully connected Dense Layer |
|
Elastic (L1 + L2) Regularization |
|
He Normal Initializer |
|
Huber Loss |
|
Lasso (L1) Regularization |
|
Abstract base class for Loss |
|
Mean Squared Loss |
|
Abstract base class for Module |
|
Abstract base class for Optimizer |
|
Abstract base class for Optimizer State |
|
Rectified Linear Unit (ReLU) |
|
Abstract base class for Regularizer |
|
Ridge (L2) Regularization |
|
SGD Optimizer |
|
Optimizer State for SGD |
|
Sequential Model |
|
Sigmoid |
|
SoftMax |
|
Softmax Cross Entropy Loss |
Class Inheritance Diagram#
vulkpy.util Module#
Utility Module (vulkpy.util
)#
Examples
>>> from vulkpy.util import enable_debug
>>> enable_debug(api_dump=False)
Functions#
|
Enable debug message |
|
Get Shader Path |