lab.generic module

lab.generic.abs[source]

Absolute value.

Parameters

a (tensor) – Tensor.

Returns

Absolute value of a.

Return type

tensor

lab.generic.add[source]

Add two tensors.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

Sum of a and b.

Return type

tensor

lab.generic.all[source]

Logical all of a tensor, possibly along an axis.

Parameters
  • a (tensor) – Tensor.

  • axis (int, optional) – Optional axis.

Returns

Reduced tensor.

Return type

tensor

lab.generic.any[source]

Logical any of a tensor, possibly along an axis.

Parameters
  • a (tensor) – Tensor.

  • axis (int, optional) – Optional axis.

Returns

Reduced tensor.

Return type

tensor

lab.generic.argsort[source]

Get the indices that would a tensor along an axis in ascending order.

Parameters
  • a (tensor) – Tensor to sort.

  • axis (int, optional) – Axis to sort along. Defaults to -1.

  • descending (bool, optional) – Sort in descending order. Defaults to False.

Returns

The indices that would sort a.

Return type

tensor

lab.generic.bvn_cdf[source]

Standard bivariate normal CDF. Computes the probability that X < a and Y < b if X ~ N(0, 1), Y ~ N(0, 1), and X and Y have correlation c.

Parameters
  • a (tensor) – First upper limit. Must be a rank-one tensor.

  • b (tensor) – Second upper limit. Must be a rank-one tensor.

  • c (tensor) – Correlation coefficient. Must be a rank-one tensor.

Returns

Probabilities of the same shape as the input.

Return type

tensor

lab.generic.cast[source]

Cast an object to another data type.

Parameters
  • dtype (dtype) – New data type.

  • a (tensor) – Tensor to cast.

Returns

a, but of data type dtype.

Return type

tensor

lab.generic.cos[source]

Cosine function.

Parameters

a (tensor) – Tensor.

Returns

Cosine function evaluated at a.

Return type

tensor

lab.generic.divide[source]

Divide two tensors.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

a divided by b.

Return type

tensor

lab.generic.erf[source]

Error function.

Parameters

a (tensor) – Tensor.

Returns

Error function evaluated at a.

Return type

tensor

lab.generic.exp[source]

Exponential function.

Parameters

a (tensor) – Tensor.

Returns

Exponential function evaluated at a.

Return type

tensor

lab.generic.eye[source]

Create an identity matrix.

Can also give a reference tensor whose data type and shape will be used to construct an identity matrix.

Parameters
  • dtype (dtype, optional) – Data type. Defaults to the default data type.

  • *shape (shape) – Shape of the matrix.

Returns

Identity matrix of shape shape and data type dtype.

Return type

tensor

lab.generic.ge[source]

Check whether one tensor is greater than or equal to another.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

a is greater than or equal to b.

Return type

tensor[bool]

lab.generic.gt[source]

Check whether one tensor is strictly greater than another.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

a is strictly greater than b.

Return type

tensor[bool]

lab.generic.identity[source]

Identity function

Parameters

a (tensor) – Tensor.

Returns

a exactly.

Return type

tensor

lab.generic.isnan[source]

Check whether a tensor is NaN.

Parameters

a (tensor) – Tensor.

Returns

a is NaN.

Return type

tensor[bool]

lab.generic.le[source]

Check whether one tensor is less than or equal to another.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

a is less than or equal to b.

Return type

tensor[bool]

lab.generic.leaky_relu[source]

Leaky rectified linear unit.

Parameters
  • a (tensor) – Input.

  • alpha (tensor) – Coefficient of leak.

Returns

Activation value.

Return type

tensor

lab.generic.linspace[source]

Create a vector of c numbers ranging from a to c, distributed linearly.

Parameters
  • dtype (dtype, optional) – Data type. Defaults to the default data type.

  • a (number) – Lower bound.

  • b (number) – Upper bound.

  • num (int) – Number of numbers.

Returns

c numbers ranging from a to c, distributed linearly.

Return type

vector

lab.generic.log[source]

Logarithmic function

Parameters

a (tensor) – Tensor.

Returns

Logarithmic function evaluated at a.

Return type

tensor

lab.generic.log_2_pi = 1.8378770664093453

Value of log(2 * pi).

lab.generic.logsumexp[source]

Exponentiate a tensor, sum it, and then take the logarithm, possibly along an axis.

Parameters
  • a (tensor) – Tensor.

  • axis (int, optional) – Optional axis.

Returns

Reduced tensor.

Return type

tensor

lab.generic.lt[source]

Check whether one tensor is strictly less than another.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

a is strictly less than b.

Return type

tensor[bool]

lab.generic.max[source]

Take the maximum of a tensor, possibly along an axis.

Parameters
  • a (tensor) – Tensor.

  • axis (int, optional) – Optional axis.

Returns

Reduced tensor.

Return type

tensor

lab.generic.maximum[source]

Take the maximum of two tensors.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

Maximum of a and b.

Return type

tensor

lab.generic.mean[source]

Take the mean of a tensor, possibly along an axis.

Parameters
  • a (tensor) – Tensor.

  • axis (int, optional) – Optional axis.

Returns

Reduced tensor.

Return type

tensor

lab.generic.min[source]

Take the minimum of a tensor, possibly along an axis.

Parameters
  • a (tensor) – Tensor.

  • axis (int, optional) – Optional axis.

Returns

Reduced tensor.

Return type

tensor

lab.generic.minimum[source]

Take the minimum of two tensors.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

Minimum of a and b.

Return type

tensor

lab.generic.multiply[source]

Multiply two tensors.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

Product of a and b.

Return type

tensor

lab.generic.nan = nan

NaN.

lab.generic.negative[source]

Negate a tensor.

Parameters

a (tensor) – Tensor.

Returns

Negative of a.

Return type

tensor

lab.generic.one[source]

Create a 1 with a particular data type.

Parameters

dtype (dtype) – Data type.

Returns

1 with data type dtype.

Return type

scalar

lab.generic.ones[source]

Create a tensor of ones.

Can also give a reference tensor whose data type and shape will be used to construct a tensor of ones.

Parameters
  • dtype (dtype, optional) – Data type. Defaults to the default data type.

  • *shape (shape) – Shape of the tensor.

Returns

Tensor of ones of shape shape and data type dtype.

Return type

tensor

lab.generic.pi = 3.141592653589793

Value of pi.

lab.generic.power[source]

Raise a tensor to a power.

Parameters
  • a (tensor) – Tensor.

  • power (tensor) – Power.

Returns

a to the power of power.

Return type

tensor

lab.generic.range[source]

Create a vector of numbers ranging from start to stop with step size step.

Parameters
  • dtype (dtype, optional) – Data type. Defaults to int.

  • start (number, optional) – Start of range. Defaults to 0.

  • stop (number) – End of range.

  • step (number, optional) – Step size. Defaults to 1.

Returns

Numbers ranging from start to stop with step size step.

Return type

vector

lab.generic.relu[source]

Rectified linear unit.

Parameters

a (tensor) – Tensor.

Returns

Rectified linear unit evaluated at a.

Return type

tensor

lab.generic.scan[source]

Perform a TensorFlow-style scanning operation.

Parameters
  • f (function) – Scanning function.

  • xs (tensor) – Tensor to scan over.

  • *init_state (tensor) – Initial state.

lab.generic.sigmoid[source]

Sigmoid function.

Parameters

a (tensor) – Tensor.

Returns

Sigmoid function evaluated at a.

Return type

tensor

lab.generic.sign[source]

Sign function.

Parameters

a (tensor) – Tensor.

Returns

Sign of a.

Return type

tensor

lab.generic.sin[source]

Sine function.

Parameters

a (tensor) – Tensor.

Returns

Sine function evaluated at a.

Return type

tensor

lab.generic.softplus[source]

Softplus function.

Parameters

a (tensor) – Tensor.

Returns

Softplus function evaluated at a.

Return type

tensor

lab.generic.sort[source]

Sort a tensor along an axis in ascending order.

Parameters
  • a (tensor) – Tensor to sort.

  • axis (int, optional) – Axis to sort along. Defaults to -1.

  • descending (bool, optional) – Sort in descending order. Defaults to False.

Returns

a, but sorted.

Return type

tensor

lab.generic.sqrt[source]

Square root.

Parameters

a (tensor) – Tensor.

Returns

Square root of a.

Return type

tensor

lab.generic.std[source]

Compute the standard deviation of a tensor, possibly along an axis.

Parameters
  • a (tensor) – Tensor.

  • axis (int, optional) – Optional axis.

Returns

Reduced tensor.

Return type

tensor

lab.generic.subtract[source]

Subtract two tensors.

Parameters
  • a (tensor) – First tensor.

  • b (tensor) – Second tensor.

Returns

a minus b.

Return type

tensor

lab.generic.sum[source]

Sum a tensor, possibly along an axis.

Parameters
  • a (tensor) – Tensor.

  • axis (int, optional) – Optional axis.

Returns

Reduced tensor.

Return type

tensor

lab.generic.tan[source]

Tangent function.

Parameters

a (tensor) – Tensor.

Returns

Tangent function evaluated at a.

Return type

tensor

lab.generic.tanh[source]

Tangent hyperbolic function.

Parameters

a (tensor) – Tensor.

Returns

Tangent hyperbolic function evaluated at a.

Return type

tensor

lab.generic.to_numpy[source]

Convert an object to NumPy.

Parameters

a (object) – Object to convert.

Returns

a as NumPy.

Return type

np.ndarray

lab.generic.zero[source]

Create a 0 with a particular data type.

Parameters

dtype (dtype) – Data type.

Returns

0 with data type dtype.

Return type

scalar

lab.generic.zeros[source]

Create a tensor of zeros.

Can also give a reference tensor whose data type and shape will be used to construct a tensor of zeros.

Parameters
  • dtype (dtype, optional) – Data type. Defaults to the default data type.

  • *shape (shape) – Shape of the tensor.

Returns

Tensor of zeros of shape shape and data type dtype.

Return type

tensor