qualia2 package¶
Subpackages¶
- qualia2.data package
- Submodules
- qualia2.data.basic module
- qualia2.data.cifar module
- qualia2.data.dataloader module
- qualia2.data.dataset module
- qualia2.data.emnist module
- qualia2.data.fashion_mnist module
- qualia2.data.fimlp module
- qualia2.data.kuzushi_mnist module
- qualia2.data.mnist module
- qualia2.data.stl10 module
- qualia2.data.transforms module
- Module contents
- qualia2.functions package
- Submodules
- qualia2.functions.activation module
- qualia2.functions.array module
- qualia2.functions.complex module
- qualia2.functions.conv module
- qualia2.functions.distance module
- qualia2.functions.dropout module
- qualia2.functions.linear_algebra module
- qualia2.functions.loss module
- qualia2.functions.normalize module
- qualia2.functions.pool module
- qualia2.functions.recurrent module
- qualia2.functions.sparse module
- qualia2.functions.trigonometric module
- qualia2.functions.ufunc module
- qualia2.functions.vision module
- Module contents
- qualia2.nn package
- Subpackages
- qualia2.nn.modules package
- Submodules
- qualia2.nn.modules.activation module
- qualia2.nn.modules.conv module
- qualia2.nn.modules.dropout module
- qualia2.nn.modules.linear module
- qualia2.nn.modules.module module
- qualia2.nn.modules.normalize module
- qualia2.nn.modules.pool module
- qualia2.nn.modules.recurrent module
- qualia2.nn.modules.sparse module
- Module contents
- qualia2.nn.modules package
- Submodules
- qualia2.nn.init module
- qualia2.nn.optim module
- Module contents
- Subpackages
- qualia2.rl package
- qualia2.text package
- qualia2.vision package
Submodules¶
qualia2.autograd module¶
-
class
qualia2.autograd.Abs(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.Function
-
class
qualia2.autograd.Add(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.FunctionAdds arrays elementwise.
-
class
qualia2.autograd.Clamp(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.Function
-
class
qualia2.autograd.Div(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.FunctionElementwise true division
-
class
qualia2.autograd.Expand_dims(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.Function
-
class
qualia2.autograd.Function(output_shape, *args, **kwargs)[source]¶ Bases:
objectAll function should inherit this class.
forward and calc_grad methods should be overwritten.
- Attributes:
output_shape (tuple(int)): output shape of a function
var (tuple(
Tensor)): Tensor(s) that was feededkwargs (dict): some useful data for backward calculation
-
class
qualia2.autograd.Gather(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.FunctionGathers values along an axis specified by dim.
-
class
qualia2.autograd.Matmul(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.Function
-
class
qualia2.autograd.Mul(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.FunctionMultiplies two arrays elementwise.
-
class
qualia2.autograd.Neg(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.FunctionTakes numerical negative elementwise.
-
class
qualia2.autograd.Pow(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.FunctionComputes a ** b elementwise.
-
class
qualia2.autograd.Reshape(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.Function
-
class
qualia2.autograd.Slice(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.Function
-
class
qualia2.autograd.Squeeze(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.Function
-
class
qualia2.autograd.Sub(output_shape, *args, **kwargs)[source]¶ Bases:
qualia2.autograd.FunctionSubtracts arguments elementwise.
-
class
qualia2.autograd.Tensor(data, requires_grad=True, dtype='float64')[source]¶ Bases:
objectWrapper class to execute automatic differentiation
- Args:
data (Union[ndarray,int,float]): tensor to compute the automatic differentiation
requires_grad (bool): Whether to store grads. If False is set, grad of the Tensor will be zeros. Default: True
dtype (str): data type of the tensor Default: ‘float64’
- Attributes:
data (ndarray): Stores data of the Tensor
grad (ndarray): Stores gradients of the Tensor
creator (Function): Stores the creator of the Tensor, which will be called at the backpropagation.
child (list): temp list of child, which will be created in a forward pass
requires_grad (bool): Whether to store grads. If False is set, grad of the Tensor will be zeros.
shape (tuple): Stores the shape of Tensor’s data
ndim (int): Stores the number of Tensor’s data dimentions
Examples:
>>> # The following example will compute the dy/dx >>> # Create Tensor objects >>> x = qualia2.array(5) >>> # Write an equation >>> y = x**2 - 2*x + 1 >>> print(y) >>> # Calclate gradiant >>> y.backward() >>> # Print `dy/dx` >>> print(x.grad)
-
property
T¶ transpose of the Tensor
- Returns:
(Tensor): transpose of the tensor
-
backward(*args)[source]¶ calculates all the gradients in the graph
- Args:
*args (ndarray): seed of the reverse accumulation AD; optional
-
clamp(low, high)[source]¶ clamp the data
- Args:
low (float): lower limit of the data.
high (float): upper limit of the data.
- Returns:
(Tensor): clamped Tensor
-
detach()[source]¶ returns a new Tensor, detached from the current graph.
- Returns:
(Tensor): a new Tensor, detached from the current graph.
-
fill(val)[source]¶ initialize the Tensor data with a constant value
- Args:
val (float|int): a value to fill the Tensor data
-
handle_const(obj)[source]¶ handles the constant object such as int or float
- Args:
obj (Union[Tensor,int,float]): constant
- Returns:
(Tensor)
-
normal(mean=0, std=1)[source]¶ initialize the Tensor data with normal distribution
- Args:
mean (float): mean of the normal distribution.
std (float): std of the normal distribution.
-
set_creator(obj)[source]¶ sets the creator of the Tensor
- Args:
obj (Function): the function that created the Tensor
qualia2.util module¶
-
class
qualia2.util.Trainer(batch, path=None)[source]¶ Bases:
objectTrainer base class
-
train(model, dataloader, optim, criterion, epochs=200, filename=None)[source]¶ trainer helps the training process of supervised learning Args:
model (Module): model to train dataloader (DataLoader): dataloader to use optim (Optimizer): optimizer to use criterion (Function): loss function to use epochs (int): number of epochs filename (string): specify the filename as well as the loading path without the file extension. (ex) path/to/filename
-
Module contents¶
-
qualia2.load(filename)[source]¶ Loads parameters saved in qla format.
- Args:
filename (str): specify the filename as well as the path to the file without the file extension. (ex) path/to/filename