Primitives

__add

__add (x0, x1)

Args:

x0 (number): An addendn”

*x1 (number list): A list of one or more addends.n”

Returns:

The sum of all addends.

__and

__and (a, b)

Args:

a (boolean) : a boolean argument *b (boolean list) : a list of boolean arguments

Returns:

The logical and of a and b.

__div

__div (num, den)

Args:

x0 (number): The numerator valuen”

*x1 (number list): A list of denominator values.n”

Returns:

The result of dividing all arguments.

__eq

__eq (arg1, arg2, arg3)

Args:

arg1 (number) : A value to compare arg2 (number) : Another value to compare arg3 (boolean, optional) : whether to use a

numeric return value.

Returns:

if arg3 is true

return 1 if arg1 == arg2, 0 otherwise.

else

return True if arg1 == arg2, False otherwise.

__ge

__ge (arg1, arg2, arg3)

Args:

arg1 (number) : A value to compare arg2 (number) : Another value to compare arg3 (boolean, optional) : whether to use a

numeric return value.

Returns:

if arg3 is true

return 1 if arg1 >= arg2, 0 otherwise.

else

return True if arg1 >= arg2, False otherwise.

__gen

__gen (arg, dtype) Args:

arg (float) : a floating point number dtype (optional, string) : the data-type of the returned array, defaults to ‘float’.

Returns:

This function implements function absolute from Python’s math library.

__gen_bool

__gen_bool (arg) Args:

arg (float) : a floating point number

Returns:

This function implements function isnan from Python’s math library.

__gt

__gt (arg1, arg2, arg3)

Args:

arg1 (number) : A value to compare arg2 (number) : Another value to compare arg3 (boolean, optional) : whether to use a

numeric return value.

Returns:

if arg3 is true

return 1 if arg1 > arg2, 0 otherwise.

else

return True if arg1 > arg2, False otherwise.

__le

__le (arg1, arg2, arg3)

Args:

arg1 (number) : A value to compare arg2 (number) : Another value to compare arg3 (boolean, optional) : whether to use a

numeric return value.

Returns:

if arg3 is true

return 1 if arg1 <= arg2, 0 otherwise.

else

return True if arg1 <= arg2, False otherwise.

__len

__len (a)

Args:

a (object)a list, dictionary, string or an array of arbitrary

dimensions

Returns:

This returns the number of elements of the given array along its outermost(leftmost) dimension.

__lt

__lt (arg1, arg2, arg3)

Args:

arg1 (number) : A value to compare arg2 (number) : Another value to compare arg3 (boolean, optional) : whether to use a

numeric return value.

Returns:

if arg3 is true

return 1 if arg1 < arg2, 0 otherwise.

else

return True if arg1 < arg2, False otherwise.

__minus

__minus (arg)

Args:

arg (number): a numeric valuen”

Returns:

The negated value arg.

__mod

__mod (x0, x1)

Args:

x0 (int): A dividend.n” x1 (int): A divisor.n”

Returns:

The remainder of the division.

__mul

__mul (x0, x1)

Args:

x0 (number): The factorn”

*x1 (number list): A list of one or more factors.n”

Returns:

The product of all factors.

__name

__name (arg)

Args:

arg (primitive type) : return the name of the arg

Returns:

The name of the primitive type

__ne

__ne (arg1, arg2, arg3)

Args:

arg1 (number) : A value to compare arg2 (number) : Another value to compare arg3 (boolean, optional) : whether to use a

numeric return value.

Returns:

if arg3 is true

return 1 if arg1 != arg2, 0 otherwise.

else

return True if arg1 != arg2, False otherwise.

__not

__not (a)

Args:

a (boolean) : a boolean argument

Returns:

The opposite of a.

__or

__or (a, b)

Args:

a (boolean) : a boolean argument *b (boolean list) : a list of boolean arguments

Returns:

The logical or of a and b.

__sub

__sub (x0, x1)

Args:

x0 (number): The value to subtract fromn”

*x1 (number list): A list of values to subtract.n”

Returns:

The difference of all arguments.

__type

__type (arg)

Args:

arg (primitive type) : return the type of the arg

Returns:

The variant index of the primitive type

__xor

__xor (a, b)

Args:

a (boolean) : a boolean argument *b (boolean list) : a list of boolean arguments

Returns:

The logical xor of a and b.

_decomposition

_decomposition (m) Args:

m (matrix): a matrix

Returns:

Computes LU decomposition of a general matrix in form of A = L*U*P where P is a permutation matrix, L is a lower triangular matrix, and U is an upper triangular matrix.

_linear_solver

_linear_solver (a, b)

Args:

a (matrix) : a matrix b (vector) : a vector

Returns:

A matrix x such that a x = b.

all

all (arg, axis, keepdims, initial)

Args:

arg (array of numbers) : the input values axis (optional, integer) : a axis to sum along keepdims (optional, boolean) : keep dimension of input

Returns:

True if all values in the matrix/vector are nonzero, False otherwise.

all_gather_d

all_gather_d (local_result)

Arg:

local_result (array) : a distributed array. A vector or matrix.

Returns:

A future holding a 2-D array with all values send

by all participating localities.

als

als (ratings, reg, num, iters, alpha, enable_output)

Args:

ratings (matrix): the matrix representing user feedback over

different items

reg (float): the regularization parameter num (integer): the number of factors iters (integer): the number of iterations alpha (float): the scaling factor enable_output(boolean): whether output should be enabled.

Returns:

The algorithm returns a list of two matrices: [X, Y] : X: user-factors matrix Y: item-factors matrix

Of possible interest: http://yifanhu.net/PUB/cf.pdf

amax

amax (a, axis, keepdims, initial, dtype)

Args:

a (vector or matrix): a scalar, a vector or a matrix axis (optional, integer): an axis to max along. By default, “

flattened input is used.

keepdims (optional, bool): If this is set to True, the axes which “

are reduced are left in the result as dimensions with size ” one. False by default

initial (optional, scalar): The minimum value of an output

element.

dtype (optional, string)the data-type of the returned array,

defaults to dtype of input array.

Returns:

Returns the maximum of an array or maximum along an axis.

amin

amin (a, axis, keepdims, initial, dtype)

Args:

a (vector or matrix): a scalar, a vector or a matrix axis (optional, integer): an axis to min along. By default, “

flattened input is used.

keepdims (optional, bool): If this is set to True, the axes which “

are reduced are left in the result as dimensions with size ” one. False by default

initial (optional, scalar): The maximum value of an output

element.

dtype (optional, string)the data-type of the returned array,

defaults to dtype of input array.

Returns:

Returns the minimum of an array or minimum along an axis.

annotate

annotate (target, args)

Args:

target : the value that has to be annotated *args (arg list) : an optional list of annotations (default is None)

Returns:

The target annotated with the list of values given by *args.

annotate_d

annotate_d (target, name, args)

Args:

target : the value that has to be annotated name : a unique string identifying the annotated object across

localities

*args (arg list) : an optional list of annotations (default is None)

Returns:

The target annotated with the list of values given by *args. The target is also identified by the given name across localities.

any

any (arg, axis, keepdims, initial)

Args:

arg (array of numbers) : the input values axis (optional, integer) : a axis to sum along keepdims (optional, boolean) : keep dimension of input

Returns:

True if any values in the matrix/vector are nonzero, False otherwise.

append

append (li,val)

Args:

li (list) : a list to which a value may be appended val (object) : a value to append

Returns:

A new list with the value val appended. Note that li is not modified by this operation.

apply

apply (func, range)

Call function func one time using the values in range as the argument list.

Args:

func(function) : a function range(iter) : an iterator with at least as many values

as function func has arguments.

Returns:

The return value of function func when called with the arguments supplied by range.

arange

arange (start, stop, step)

Args:

start (number)Start of interval. The interval includes this

value. The default start value is 0.

stop (number)End of interval. The interval does not include

this value, except in some cases where step is not an integer and floating point round-off affects the length of out.

step (number, optional)Spacing between values. For any

output out, this is the distance between two adjacent values, out[i+1] - out[i]. The default step size is 1. If step is specified as a position argument, start must also be given.

dtype (nil, optional)the data-type of the returned array,

defaults to dtype of input arrays.

Returns:

Array of evenly spaced values. For floating point arguments, the length of the result is ceil((stop - start)/step). Because of floating point overflow, this rule may result in the last element of out being greater than stop.

argmax

argmax (a, axis)

Args:

a (array) : a vector, matrix, or tensor axis (optional, int): the axis along which to find the max

Returns:

The index of the maximum value in the array. If an axis is specified, a vector of maxima along the axis is returned.

argmax_d

argmax_d (a, axis)

Args:

a (array) : a vector, matrix, or tensor axis (optional, int): the axis along which to find the max

Returns:

The index of the maximum value in the array. If an axis is specified, a vector of maxima along the axis is returned.

argmin

argmin (a, axis)

Args:

a (array) : a vector, matrix, or tensor axis (optional, int) : the axis along which to find the min

Returns:

The index of the minimum value in the array. If an axis is specified, a vector of minima along the axis is returned.

argmin_d

argmin_d (a, axis)

Args:

a (array) : a vector, matrix, or tensor axis (optional, int) : the axis along which to find the min

Returns:

The index of the minimum value in the array. If an axis is specified, a vector of minima along the axis is returned.

argsort

argsort (a, axis, kind, order)

Args:

a (array_like):

An array to sort.

axis (optional, {int, nil}):

Axis along which to sort. The default is -1 (the last axis). If nil, the flattend array is used.

kind (optional, {‘quicksort’, ‘merrgesort’, ‘heapsort’, ‘stable’}):

Sorting algorithm. * ignored *

order (optional, {str, list of str}):

When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. A single field can be specified as a string, and not all fields need be specified, but unspecified fields will still be used, in the order in which they come up in the dtype, to break ties. * ignored *

Returns:

index_array ({ndarray, int}): When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. A single field can be specified as a string, and not all fields need be specified, but unspecified fields will still be used, in the order in which they come up in the dtype, to break ties.

source: https://docs.scipy.org/doc/numpy/reference/generated/numpy.argsort.html#numpy.argsort.

assert

assert (cond, msg)

Args:

cond (boolean expression) : if not true, raise an AssertionError msg (any expression) : if given, the evaluated result is printed

Returns:

astype

astype (x, dtype)

Args:

x (array) : the array to be cast to the specified type dtype : the data-type to which the array is cast

Returns:

Copy of the array, cast to a specified type.

async

async (expr)

Args:

expran arbitrary expression that will be evaluated

asynchronously

Returns:n”

Returns a future representing the result of the evaluation of the given expression

avg_pool2d

avg_pool2d (x, pool_size, padding, strides)

Args:

x (array) : a 4d array pool_size (a tuple of two integers) : the size of pooling over the

2nd and the 3rd dimensions

padding (optional, string)padding mode, it can be either same

or valid. valid by default.

strides (optional, a tuple of 2 integers)the step to apply

pooling over the 2nd and the the 3rd dimensions. (1, 1) by default.

Returns:

The result of 2d avg pooling with pool_size filters

avg_pool3d

avg_pool3d (x, pool_size, padding, strides)

Args:

x (array) : a tensor pool_size (a tuple of 3 integers) : the size of pooling over each

dimension

padding (optional, string)padding mode, it can be either same

or valid. Padding is valid by default.

strides (optional, a tuple of 3 integers)the step to apply

pooling over each dimension. (1, 1, 1) by default.

Returns:

The result of 3d avg pooling with pool_size filters

batch_dot

batch_dot (x, y, axes)

Args:

x (array) : a matrix or a tensor y (array) : a matrix or a tensor axes (optional, integer or tuple of integers): None by default.

Target dimensions to be reduced.

Returns: The batch dot along specified axes. For more deyail refer to https://keras.io/backend/#batch_dot

bias_add

bias_add (x, bias)

Args:

x (array_like) : input array of at least rank 2 bias (array_like): a bias vector or an array of x_dims-1 dimensions

Returns:

Adds a bias array to an array

binary_crossentropy

binary_crossentropy (target, output, from_logits)

Args:

target (array_like) : input array output (array_like) : this array is not output back to the caller

but is passed back with the return values.

from_logits (optional, boolean): boolean value, default = False

Returns:

The value should be the same as would be returned by the following Python function:

def bin_cross(target, output, from_logits=False):
if not from_logits:

output = np.clip(output, 1e-7, 1 - 1e-7) output = np.log(output / (1 - output))

return (target * -np.log(sigmoid(output)) +

(1 - target) * -np.log(1 - sigmoid(output)))

block

block (stmt)

Args:

*stmt (statement list) : a list of statements.

Returns:

The value of the last statement.

cannon_product_d

cannon_product_d (a, b)

Args:

a (array) : a matrix b (array) : a matrix

Returns:

The dot product of two matrices: a and b using Cannon’s algorithm. The dot product of an MxN matrix and an NxL is of size MxL

car_cdr

car_cdr (li)

Args:

li (list) : a list

Returns:

car returns the head of a list, e.g. car([1 ,2, 3]) returns 1 cdr returns the tail of a list, e.g. cdr([1, 2, 3]) returns [2, 3] caar() is the same as car(car()) cadr() is the same as car(cdr()) etc.

categorical_crossentropy

categorical_crossentropy (target, output, from_logits)

Args:

target (array_like) : input array output (array_like) : this array is not output back to the caller

but is passed back with the return values.

from_logits (optional, boolean): boolean value, default = False axis (optional, integer: integer axis, default = -1

Returns:

The value should be the same as would be returned by the following Python function:

def categorical_crossentropy(target, output, from_logits=False, axis=True):
if from_logits:

axis = -1 outval = softmax(output, axis=axis)

else:

outval /= output.sum(axis=axis, keepdims=True)

outval = np.clip(output, 1e-7, 1 - 1e-7) res = np.sum(target * -np.log(outval), axis=axis, keepdims=False) return res, outval

clip

clip (a, axis)

Args:

a (array_like) : array containing elements to clip a_min : Minimum value, it may be scalar or array_like or None a_max : Maximum valus, it may be scalar or array_like or None

Returns:

An array with the elements of a, but where values < a_min are replaced with a_min, and those > a_max with a_max.”

concatenate

concatenate (ar, axis)

Args:

ar (array) : sequence of array_like axis (optional, int) : the axis along which the arrays will be

joined, default is 0, if axis is None arrays are flattened before use

Returns:

The joined sequence of arrays along an existing axis.”

constant

constant (value, shape, dtype)

Args:

value (float): a constant value, if ‘None’ this operation

returns an uninitialized array-like, also in this case ‘shape’ should not be ‘None’

shape (int or shape, optional): the number of values dtype (string, optional): the data-type of the returned array,

defaults to ‘float’.

Returns:

An array of size ‘shape’ with each element equal to ‘value’. If ‘value’ is equal to None, the array elements are uninitialized.

constant_d

constant_d (value, shape, tile_index, numtiles, name, tiling_type, intersection,)

dtype Args:

value (float): fill value shape (int or list of ints): overall shape of the array. It

only contains positive integers.

tile_index (int, optional): the tile index we need to generate

the constant array for. A non-negative integer. If not given, it sets to current locality.

numtiles (int, optional): number of tiles of the returned array.

if not given it sets to the number of localities in the application.

name (string, optional): the array given name. If not given, a

globally unique name will be generated.

tiling_type (string, optional): defaults to sym which is a

balanced way of tiling among all the numtiles localities. Other options are page, row or column tiling. For a vector all these three tiling_type are the same.

intersection (int or a tuple of ints, optional): the size of

overlapped part on each dimension. If an integer is given, that would be the intersection length on all dimensions that are tiled. The middle parts get to have two intersections, one with the tile before it and one with the tile after it.

dtype (string, optional): the data-type of the returned array,

defaults to ‘float’.

Returns:

A part of an array of size ‘shape’ with each element equal to ‘value’, which has the tile index of ‘tile_index’.

constant_like

constant_like (value, a, dtype)

Args:

value (float): a constant value, if ‘None’ this operation

returns an uninitialized array-like

a (array-like): the shape of this array-like will be used as

to determine the shape of the result

dtype (string, optional): the data-type of the returned array,

defaults to ‘float’.

Returns:

An array of the same size as ‘a’ with each element equal to ‘value’. If ‘value’ is equal to None, the array elements are uninitialized.

conv1d

conv1d (x, kernel, padding, strides, dilation_rate)

Args:

x (array)a 3d array consiting of batch, in_length and

in_channels dimensions.

kernel (array)a 3d array consisting of filter_length,

in_channels and out_channels dimension. Note that the in_channels should be the same in kernel and original array.

padding (optional, string)padding mode, valid by default. It

can be either valid, same or causal. vaild means no padding. same results the output with the same shape as original array in case of unit strides. causal zero pads the array in a way that no output element depend on the input elements of its future.

strides (optional, integer)the step to apply convolution over

array. It sets to 1 by default.

dilation_rate (optional, integer)indicates the dilation rate,

the rate to sample the array in each step of convolution, 1 by default.

Returns:

1D convolution (or 1D mathematical cross-correlation)

conv1d_d

conv1d_d (x, kernel, padding, strides, dilation_rate, name)
Args:
x (array)a 3d array consiting of batch, in_length and

in_channels dimensions.

kernel (array)a 3d array consisting of filter_length,

in_channels and out_channels dimension. Note that the in_channels should be the same in kernel and original array.

padding (optional, string)padding mode, valid by default. It

can be either valid, same or causal. vaild means no padding. same results the output with the same shape as original array in case of unit strides. causal zero pads the array in a way that no output element depend on the input elements of its future.

strides (optional, integer)the step to apply convolution over

array. It sets to 1 by default.

dilation_rate (optional, integer)indicates the dilation rate,

the rate to sample the array in each step of convolution, 1 by default.

name (optional, string): the result name. If not given it will be

the same as the next generation of the original distributed array.

Returns: 1D convolution (or 1D mathematical cross-correlation)

conv2d

conv2d (x, kernel, padding, strides, dilation_rate)

Args:

x (array)a 4d array consiting of batch, in_height, in_width and

in_channels dimensions.

kernel (array)a 4d array consisting of filter_height,

filter_width, in_channels and out_channels dimension. Note that the in_channels should be the same in kernel and original array.

padding (optional, string)padding mode, valid by default. It

can be either valid or same. vaild means no padding. same results the output with the same shape as original array in case of unit strides.

strides (optional, a tuple of two integers)the steps to apply

convolution over height and width of the array. It sets to (1,1) by default.

dilation_rate (optional, a tuple of two integers)indicates the

dilation rate, the rate to sample the height and the width of the array in each step of convolution, (1,1) by default.

Returns:

2D convolution (or 2D mathematical cross-correlation)

conv2d_transpose

conv2d_transpose (x, kernel, padding, strides, dilation_rate)

Args:

x (array)a 4d array consisting of batch, in_height, in_width and

in_channels dimensions.

kernel (array)a 4d array consisting of filter_height,

filter_width, out_channels and in_channels dimension. Note that the in_channels should be the same in kernel and original array.

output_shape (vector of 4 integers): shape of the output consisting

of batch, output_height, output_width, out_channels

padding (optional, string)padding mode, valid by default. It

can be either valid or same. valid means no padding. same results the output with the same shape as original array in case of unit strides.

strides (optional, a tuple of two integers)the steps to apply

convolution over height and width of the array. It sets to (1,1) by default.

dilation_rate (optional, a tuple of two integers)indicates the

dilation rate, the rate to sample the height and the width of the array in each step of convolution, (1,1) by default.

Returns:

2D deconvolution

count_nonzero

count_nonzero (ar)

Args:

ar (array) : a numeric array of values

Returns:

The number of array elements that are not zero.

cout

cout (args)

Args:

*args (list of variables)print a string representation

of the variables to stdout.

Returns:

cross

cross (v1, v2)

Args:

v1 (vector) : a vector v2 (vector) : a vector

Returns:

The cross product of v1 and v2.

ctc_decode

ctc_decode (y_pred, input_length, greedy, beam_width, top_paths)

Args:

y_pred (scalar, vector, matrix, or tensor)The variable to perform

ctc_decode over

input_length (list) : a list of input lengths greedy (bool) : if True performs best-path search otherwise beam-search beam_width (int) : if greedy is False specifies the width of the beam. top_paths (int) : if greedy is False specifies the number of top paths

desired.

Returns:

Returns the result of Connectionist temporal classification applied to a squence.

cumprod

cumprod (a, axis)

Args:

a (array_like) : input array axis (int, optional) : Axis along which the cumulative product is

computed. The default (None) is to compute the cumprod over the flattened array.

dtype (string, optional)the data-type of the returned array,

defaults to dtype of input arrays.

Returns:

Return the cumulative product of the elements along a given axis.

cumsum

cumsum (a, axis)

Args:

a (array_like) : input array axis (int, optional) : Axis along which the cumulative sum is

computed. The default (None) is to compute the cumsum over the flattened array.

dtype (nil, optional)the data-type of the returned array,

defaults to dtype of input arrays.

Returns:

Return the cumulative sum of the elements along a given axis.

debug

debug (args)

Args:

*args (list of variables)print a string representation

of the variables to stderr.

Returns:

define

define (name, args, body)

Args:

name (string) : name of symbol to define args (optional, list of symbols) : if present,

this defines a function.

body (expression)value to bind to symbol name

or body of lambda function.

Returns:

<nothing>

define_global

define_global (name)

Args:

name (string) : name of symbol to define globally

Returns:

<nothing>

determinant

determinant (arg)

Args:

arg (matrix) : a square matrix of numbers

Returns:

The determinant of the matrix represented by arg.

diag

diag (m)

Args:

m (matrix) : a square matrix

Returns:

A vector created from the diagonal elements of m.

diag_d

diag_d (arr, k, tiling_type, tile_index, numtiles)
Args:

arr (array): a distributed array. A vector. k (int, optional): The default is 0. Denote the diagonal above

the main diagonal when k > 0 and the diagonal below the main diagonal when k < 0.

tiling_type (string, optional): defaults to sym. Other

options are row or column tiling.

tile_index (int, optional): the tile index we need to generate

the diag array for. A non-negative integer. If not given, it sets to current locality.

numtiles (int, optional): number of tiles of the returned array.

If not given it sets to the number of localities in the application.

Returns:

A 2-D array with arr on the k-th diagonal.

dict

dict (lili)

Args:

lili (list of lists, optional) : a list of 2-element lists

Returns:

The dict primitive returns a dictionary object constructed from a list of 2-element lists. The 2-element lists provide a key in the first element and a value in the second.

dot

dot (a, b)

Args:

a (array) : a scalar, vector, matrix or a tensor b (array) : a scalar, vector, matrix or a tensor

Returns:

The dot product of two arrays: a and b. The dot product of an N-D array and an M-D array is of dimension N+M-2

dot_d

dot_d (a, b)

Args:

a (array) : a scalar, vector, matrix or a tensor b (array) : a scalar, vector, matrix or a tensor

Returns:

The dot product of two arrays: a and b. The dot product of an N-D array and an M-D array is of dimension N+M-2

dstack

dstack (args, dtype)

Args:

*args (list, optional) : a list of array-like objects dtype (optional, string) : the data-type of the returned array,

defaults to dtype of input arrays.

Returns:

A vertically (depth wise) stacked sequence of array-like objects

elu

elu (a)

Args:

a (array_like) : input array alpha (optional, number) : scale for the negative factor

Returns:

Returns an array of the same shape that is the exponential linear unit of the input and is defined as: * f(x) = alpha * (exp(x) - 1.) for x < 0, * f(x) = x for x >= 0.

enable_tracing

enable_tracing (eon)

Args:

eon (boolean) : set to true/false to enable/disable tracing.

Returns:

expand_dims

expand_dims (arg, axis)

Args:

arg (number or list of numbers): number or list of numbers axis (integer): an axis to expand along

Returns:

Expand the shape of an array by adding a dimension.

eye

eye (N, M, k, dtype)

Args:

N (integer) : number of rows in the output. M (optional, integer) : number of columns in the output. If

None, defaults to N.

k (optional, integer)index of the diagonal: 0 (the default)

refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal.

dtype (optional, string)the data-type of the returned array,

defaults to ‘float’.

Returns:

Return an N x M matrix with ones on the k-th diagonal and zeros elsewhere.

file_read

file_read (fname)

Args:

fname (string) : a file name

Returns:

An object deserialized from the data in fname.

file_read_csv

file_read_csv (filename, mode3d, page_nrows)

Args:

filename (string) : file name mode3d (bool, optional) : If sets to true, the result will be a

3d array. Each page_nrows rows of the data is stored in a new page of the result.

page_nrows (int, optional)it is used only whenmode3d is true.

It determines the number of rows in each page of the resulted array.

Returns:

Returns an array representation of the contents of a csv file.

file_read_csv_d

file_read_csv_d (filename, tiling_type, intersection, name, numtiles)

Args:

filename (string) : file name including its path. mode3d (bool, optional) : If sets to true, the result will be a

3d array. Each page_nrows rows of the data is stored in a new page of the result.

page_nrows (int, optional)it is used only whenmode3d is true.

It determines the number of rows in each page of the resulted array.

tiling_type (string, optional): defaults to sym which is a

balanced way of tiling among all the numtiles localities. Other options are page, row or column tiling. For a vector all these three tiling_type are the same.

intersection (int or a tuple of ints, optional): the size of

overlapped part on each dimension. If an integer is given, that would be the intersection length on all dimensions that are tiled. The middle parts get to have two intersections, one with the tile before it and one with the tile after it.

name (string, optional): the array given name. If not given, a

globally unique name will be generated.

numtiles (int, optional): number of tiles of the returned array.

if not given it sets to the number of localities in the application.

Returns:

Returns a distributed array representing the contents of the given csv file.

file_write

file_write (fname, obj)

Args:

fname (string): the file in which to save the data obj (object): the object to serialize

Returns:

file_write_csv

file_write_csv (fname, m)

Args:

fname (string): a file name m (array or matrix): an object to store in the file.

Returns:

The matrix written.

filter

filter (func, iter)

Args:

func (function): a function that takes one arg and returns a

boolean

iter (iterator): an iterator

Returns:n”

Filter applies func to each item in iter and creates a list consisting of the values for which func evaluated to true.

Example:

from phylanx.ast import Phylanx

@Phylanx def foo():

print(filter(lambda a : a > 1, [1, 2, 3, 4]))

foo()

Prints [2, 3, 4]

find_all_localities

find_all_localities (Args:)

Returns:

All the localities available on the system.

flatten

flatten (a, order)

Args:

a (array) : a scalar, vector, matrix or a tensor order (optional, char): ‘C’ means row-major(C-style),

‘F’ means column-major(Fortran-style), The default is ‘C’.

Returns:

A copy of the array collapsed into one dimension.”

flip

flip (a, axes)

Args:

a (array) : a scalar, a vector a matrix or a tensor axes (optional, integer or tuple of integers): an axis to flip

over. The default, axis=None, will flip over all of the axes of the input array.

Returns:

Reverses the order of elements in an array along the given axes

fliplr

fliplr (a)

Args:

a (array) : a matrix or a tensor

Returns:

Flip array in the left/right direction

flipud

flipud (a)

Args:

a (array) : a vector a matrix or a tensor

Returns:

Flip array in the up/down direction

fmap

fmap (func, listv)

Args:

func (function) : a function that takes one argument listv (iterator) : a set of values

Returns:

A new list created by applying the function func to each item in list listv.

fold_left

fold_left (func, initial, data)

Args:

func (function)a function that takes two arbitrary arguments

and returns the result of folding the two arguments

initial (int or None) : an initial value data (list or array) : the data to operate on

Returns:

The result of left-folding the elements of the data object using the given function.

This function is equivalent to the Python code:

def fl(f, i, r):

c = i for n in r:

c = f(c, n)

return c

Example(s):

@Phylanx def foo():

v = fold_left(lambda a, b : 2 * a - b, 3, [1, 2, 3]) print(v)

foo()

Result:

13

fold_right

fold_right (func, initial, data)

Args:

func (function)a function that takes two arbitrary arguments

and returns the result of folding the two arguments

initial (int or None) : an initial value data (list or array) : the data to operate on

Returns:

The result of right-folding the elements of the data object using the given function.

This function is equivalent to the Python code:

def fr(f, i, r):

c = i for n in r:

c = f(n, c)

return c

Example(s):

@Phylanx def foo():

v = fold_right(lambda a, b : 2 * a - b, 3, [1, 2, 3]) print(v)

foo()

Result:

1

for

for (init, cond, reinit, body)

Args:

init (statements) : initialize loop variables cond (expression) : boolean expression, if true the loop continues reinit (statements) : update variables evaluated by cond body (statements) : code to execute as the body of the loop

Returns:

The value returned from the last iteration, nil otherwise.

for_each

for_each (func, range)

The for_each primitive calls a function func for each item in the iterator. Args:

func (function): a function that takes one argument range (iter): an iterator

Returns:

The value returned from the last iteration, nil otherwise.

Examples:

@Phylanx def foo():

for_each(lambda a : print(a), [1, 2])

foo()

Prints 1 and 2 on individual lines.

format

format (s,args)

Args:

s (string) : a format string *args (arg list, optional) : a list of arguments

Returns:

A formatted string, with each {} in s replaced by a value from *args.

fromfunction

fromfunction (function, dimensions, dtype)

Args:

function (callable)The function is called with N parameters,

where N is the rank of ‘dimension’. Each parameter represents the coordinates of the array varying along a specific axis.

dimensions (list of integers)the shape of the array, which

also determines the shape of the coordinate arrays passed to ‘function’.

dtype (optional, string)data-type of the coordinate arrays

passed to ‘function’, default is ‘float’.

Returns:

The result of the call to ‘function’ is passed back directly. Therefore the shape of fromfunction is completely determined by ‘function’. If ‘function’ returns a scalar value, the shape of fromfunction would not match the shape parameter.

full

full (shape, value, dtype)

Args:

shape (int or shape): the number of values value (float): a constant value dtype (string, optional): the data-type of the returned array,

defaults to the data type of ‘value’, also in this case ‘value’ should not be ‘None’.

Returns:

An array of size ‘shape’ with each element equal to ‘value’. If ‘value’ is equal to None, the array elements are uninitialized.

full_like

full_like (value, a, dtype)

Args:

a (array-like): the shape of this array-like will be used as

to determine the shape of the result

value (float): a constant value, if ‘None’ this operation

returns an uninitialized array-like

dtype (string, optional): the data-type of the returned array,

defaults to ‘float’. If not specified the result’s dtype is taken from the array ‘a’.

Returns:

An array of the same size as ‘a’ with each element equal to ‘value’. If ‘value’ is equal to None, the array elements are uninitialized.

get_seed_action

get_seed_action (Args:)

Returns:

The seed used to generate random numbers.

gradient

gradient (m, axis)

Args:

m (vector or matrix) : values to take the gradient of axis (optional, integer) : the axis along which to take the gradient

Returns:

The numerical gradient, i.e., differences of adjacent values along the specified axis.

hard_sigmoid

hard_sigmoid (a)

Args:

a (array_like) : input array

Returns:

Returns an array of the same shape which is the Segment-wise linear approximation of the sigmoid function.

hostname

hostname (hostname)

Args:

none

Returns:

The hostname of the currently executing code

hsplit

hsplit (args)

Args:

*args (m - matrix or row vector, N - number of blocks)

Returns:

An N by 1 matrix of horizontal partitions of m

hstack

hstack (args, dtype)

Args:

*args (list, optional) : a list of array-like objects dtype (optional, string) : the data-type of the returned array,

defaults to dtype of input arrays.

Returns:

A horizontally (column wise) stacked sequence of array-like objects

identity

identity (n, dtype)

Args:

n (int) : the size of a created (n x n) matrix dtype (optional, string) : the data-type of the returned array,

defaults to ‘float’.

Returns:

An identity matrix of size sz by sz.

identity_d

identity_d (sz, dtype, tile_index, numtiles, name, tiling_type,)
Args:

sz (int): the size of a created (n x n) matrix. tile_index (int, optional): the tile index we need to generate

the identity array for. A non-negative integer. If not given, it sets to current locality.

numtiles (int, optional): number of tiles of the returned array.

If not given it sets to the number of localities in the application.

name (string, optional): the array given name. If not given, a

globally unique name will be generated.

tiling_type (string, optional): defaults to sym which is a

balanced way of tiling among all the numtiles localities. Other options are row or column tiling.

dtype (string, optional): the data-type of the returned array,

defaults to ‘float’.

Returns:

A part of an array of size ‘size’, which has the tile index of

‘tile_index’.

if

if (cond, thenf, elsef)

This primitive implements the if statement in Python. The statement thenf is evaluated if cond is True and the statement elsef is evaluated otherwise.

Args:

cond (boolean expression) : a boolean expression thenf (statement) : a statement elsef (statement, optional) : a statement

Returns:

The value returned by the statement that was executed, nil otherwise

indices

indices (dimensions, dtype, sparse)

Args:

dimensions (list of integers) : the shape of the grid dtype (optional, string) : the data-type of the returned array,

defaults to ‘int’.

sparse (optional, bool)return a sparse representation of the

grid instead of a dense representation, defaults to ‘false’

Returns:

One array or tuple of arrays.

insert

insert (arr, obj, values, axis, dtype)

Args:

arr (array_like) : input array obj (int, slice or sequence of ints) : Object that defines the

index or indices before which values is inserted.

values (array_like) : Values to insert into arr. axis (int, optional) : Axis along which to insert values. If

axis is None then arr is flattened first.

dtype (optional, string)the data-type of the returned array,

defaults to ‘float’.

Returns:

A copy of arr with values inserted.

invGJE

invGJE (invGJE(matrix))

Args:

matrix (vector<vector<double>>)

Returns:

the inverse of the matrix

inverse

inverse (m)

Args:

m (matrix): a scalar, matrix, or tensor

Returns:

The multiplicative inverse of m.

inverse_d

inverse_d (inverse_d(matrix))
Args:

blaze dynamic matrix

Returns:

the inverse of the matrix

kmeans

kmeans (points, num_centroids, iterations, show_result, seed,)

initial_centroids

Args:

points (matrix): a matrix with any number of rows and two

columns. Any data that can be represented by two features can create the point matrix.

num_centroids (int, optional): the number of clusters in which

we need to break down the data. It sets to 3 by default

iterations (int, optional): the number of iterations. It sets

to 10 by default.

show_result (bool, optional): defaults to false. seed (int) : the seed of a random number generator. initial_centroids (matrix): if not given, the centroids are

initialized by num_centroids randomly chosen points. If given there is no use for a seed. The initial_centroids matrix should have num_centroids rows and 2 columns.

Returns:

Number of centroids points that shows the center of clusters given the points matrix.

l2_normalize

l2_normalize (a, axis)

Args:

a (array_like) : input array axis (optional, integer): axis along which to perform normalization

The default value is None.

Returns:

Normalizes an array with respect to the L2 norm alongside the specified axis.

lambda

lambda (args, body)

Args:

*args (argument list): the list of arguments body (statement): the body of the lambda function

Returns:

A function object with the arguments and body specified.

linearmatrix

linearmatrix (nx, ny, x0, dx, dy)

Args:

nx (int) : number of rows ny (int) : number of columns x0 (number) : value of the 0,0 element dx (number) : increment in value in the x-direction dy (number) : increment in value in the y-direction

Returns:

A matrix of size nx by ny with values beginning at x0 and increasing by dx (or dy) as x (or y) is increased.

linspace

linspace (start, end, nelements)

Args:

start (number) : the start of the numeric range end (number) : the end of the numeric range nelements (int) : the number of elements

Returns:

An array with the requested number of elements, the first ” of which is start, and the last is end.

list

list (args)

Args:

*args (list of values, optional): a list of values

Returns:

A Phylanx list populated by the values supplied.

locality

locality (find_here)

Args:

none

Returns:

The locality id of the currently executing code

logical_and

logical_and (a, b)

Args:

a (boolean) : a boolean argument *b (boolean list) : a list of boolean arguments

Returns:

The logical and of a and b.

logical_not

logical_not (a)

Args:

a (boolean) : a boolean argument

Returns:

The opposite of a.

logical_or

logical_or (a, b)

Args:

a (boolean) : a boolean argument *b (boolean list) : a list of boolean arguments

Returns:

The logical or of a and b.

logical_xor

logical_xor (a, b)

Args:

a (boolean) : a boolean argument *b (boolean list) : a list of boolean arguments

Returns:

The logical xor of a and b.

logsumexp

logsumexp (arg, axis, keepdims, initial, dummy_, dtype)

Args:

arg (array of numbers) : the input values axis (optional, integer) : a axis to sum along keepdims (optional, boolean) : keep dimension of input dummy_ (nil) : unused dtype (optional, string) : the data-type of the returned array,

defaults to dtype of input array.

Returns:

The log of the sum of exponentials of input elements.

lra

lra (x, y, alpha, iters, enable_output)

Args:

x (matrix) : a matrix y (vector) : a vector

the data

alpha (float): It is the learning rate iters (int): The number of iterations enable_output (optional, boolean): If enabled, prints out the step

number and weights during each iteration

Returns:

The Calculated weights

make_list

make_list (args)

Args:

*args (list of values, optional): a list of values

Returns:

A Phylanx list populated by the values supplied.

max_pool2d

max_pool2d (x, pool_size, padding, strides)

Args:

x (array) : a 4d array pool_size (a tuple of two integers) : the size of pooling over the

2nd and the 3rd dimensions

padding (optional, string)padding mode, it can be either same

or valid. valid by default.

strides (optional, a tuple of two integers)the step to apply

pooling over the 2nd and the 3rd dimensions. (1, 1) by default.

Returns:

The result of 2d max pooling with pool_size filters

max_pool3d

max_pool3d (x, pool_size, padding, strides)

Args:

x (array) : a tensor pool_size (a tuple of 3 integers) : the size of pooling over each

dimension

padding (optional, string)padding mode, it can be either same

or valid. Padding is valid by default.

strides (optional, a tuple of 3 integers)the step to apply

pooling over each dimension. (1, 1, 1) by default.

Returns:

The result of 3d max pooling with pool_size filters

maximum

maximum (x0, x1)

Args:

x0 (number): An addendn”

*x1 (number list): A list of one or more arrays.n”

Returns:

The element-wise maximum of all input arrays.

mean

mean (arg, axis, keepdims, initial, dummy_, dtype)

Args:

arg (array of numbers) : the input values axis (optional, integer) : a axis to sum along keepdims (optional, boolean) : keep dimension of input dummy_ (nil) : unused dtype (optional, string) : the data-type of the returned array,

defaults to dtype of input array.

Returns:

The mean of the array. If an axis is specified, the result is the vector created when the mean is taken along the specified axis.

minimum

minimum (x0, x1)

Args:

x0 (number): An addendn”

*x1 (number list): A list of one or more arrays.n”

Returns:

The element-wise minimum of all input arrays.

ndim

ndim (a)

Args:

a (array type): array to extract the number of dimensions for

Returns:

Number of array dimensions.

nonzero

nonzero (arg)

Args:

arg (vector or matrix) : a vector or matrix

Returns:

A 1D array containing the indices of the elements of arg that are non-zero.

norm

norm (x, ord, axis, keepdims)

Args:

x (array_like)Input array. If axis is None, x must be 1-D or

2-D, unless ord is None. If both axis and ord are None, the 2-norm of x.ravel will be returned.

ord (int, float, string, v)non-zero int, inf, -inf,

‘fro’, or ‘nuc’. Order of the norm. The default is None.

axis (int, optional)None, int, 2-tuple of ints.

If axis is an integer, it specifies the axis of x along which to compute the vector norms. If axis is a 2-tuple, it specifies the axes that hold 2-D matrices, and the matrix norms of these matrices are computed. If axis is None then either a vector norm (when x is 1-D) or a matrix norm (when x is 2-D) is returned. The default is None.

keepdims (bool, optional)If this is set to True, the axes

which are normed over are left in the result as dimensions with size one. With this option the result will broadcast correctly against the original x. The default is false.

Returns:

Norm of the matrix or vector(s).

num_localities

num_localities (num_localities)

Args:

none

Returns:

The number of localities of the currently executing code

one_hot

one_hot (indices, num_classes)

Args:

indices (array_like)input array of integers. nD integer tensor

of shape (batch_size, dim1, dim2, … dim(n-1))

num_classes (integer): number of classes to consider

Returns:

(n + 1)D one hot representation of the input with shape (batch_size, dim1, dim2, … dim(n-1), num_classes).

outer

outer (a, b)

Args:

a (array)a scalar, vector, matrix or a tensor.Input is

flattened if not already 1-dimensional.

b (array)a scalar, vector, matrix or a tensor.Input is

flattened if not already 1-dimensional.

Returns:

Computes the outer product of two arrays. Always returns a matrix

pad

pad (a, pad_width, mode, constant_values)

Args:

a (array_like of rank N) : array containing elements to pad pad_width(sequence, array_like, int) : number of values padded to the

edges of each axis

mode(str)‘constant’ pads with a constant value

(other modes have not been implemented yet)

constant_values(sequence or int)Used in ‘constant’.

The values to set the padded values for each axis. Default is 0

Returns:

Padded array of rank equal to array with shape increased according to pad_width.”

parallel_block

parallel_block (*args)

Args:

*args (list)a list of zero or more statements

to be evaluated in parallel.

Returns:

The result as returned from the last statement in the list args.

parallel_map

parallel_map (func, listv)

Args:

func (function) : A function that takes a single argument listv (iterator) : A sequence of values to apply the function to

Returns:

A list of values obtained by apply func to every value it listv in parallel.

Examples:

print(parallel_map(lambda a : a * a, [1, 2, 3]))

Evaluates to [1, 4, 9]

power

power (base, pow)

Args:

base (float) : the base of the exponent pow (float) : the power of the exponent

Returns:

The value base`**`pow.

prepend

prepend (val,li)

Args:

val (object) : a value to prepend to the list ‘li’ li (list) : a list to which a value should be pre-pended

Returns:

A new list with the value val pre-pended. Note that li is not modified by this operation.

prod

prod (v, axis, keepdims, initial, dtype)

Args:

v (vector or matrix) : a vector or matrix axis (optional, integer): a axis to sum along keepdims (optional, boolean): keep dimension of input initial (optional, scalar): The starting value for the product dtype (optional, string) : the data-type of the returned array,

defaults to dtype of input array.

Returns:

The product of all values along the specified axis.

randn

randn (dN*)

Args:

dN (integer)The dimensions of the returned array, must be

non-negative. If no argument is given a single Python float is returned.

Returns:

Return an array filled with random numbers from the “standard normal” distribution.

random

random (size, dist, dtype)

Args:

size (int or tuple of ints)the size of the array of random

numbers to generate

dist (optional, string or list)the name of the

distribution, or a list that begins with the name and is followed by up to two numeric parameters.

dtype (optional, string)the data-type of the returned array,

defaults to ‘float’.

Returns:

An array of random numbers.

random_d

random_d (shape, tile_index, numtiles, name, tiling_type, mean, std)

Args:

shape (int or list of ints): overall shape of the array. It

only contains positive integers.

tile_index (int, optional): the tile index we need to generate

the random array for. A non-negative integer. If not given, it sets to current locality.

numtiles (int, optional): number of tiles of the returned array

if not given it sets to the number of localities in the application.

name (string, optional): the array given name. If not given, a

globally unique name will be generated.

tiling_type (string, optional): defaults to sym which is a

balanced way of tiling among all the numtiles localities. Other options are page, row or column tiling. For a vector, all these three tiling_types are the same.

mean (float, optional): the mean value of the distribution. It

sets to 0.0 by default.

std (float, optional): the standard deviation of the normal

distribution. It sets to 1.0 by default.

Returns:

A part of an array of random numbers on tile_index-th tile out of numtiles using the normal distribution

random_integers

random_integers (low, high, size)

Args:

low (int)Lowest (signed) integer to be drawn from the

distribution (unless high=nil, in which case this parameter is the highest such integer, the lowest in this case is 1).

high (int, optional)If provided, the largest (signed) integer

to be drawn from the distribution

size (int or tuple of ints, optional)the size of the array of

random numbers to generate

Returns:

An array of random numbers.

random_sample

random_sample (size)

Args:

size (int or tuple of ints)the size of the array of random

numbers to generate

Returns:

An array of random numbers.

range

range (start, end, step)

Args:

start (number) : a starting value end (optional, number) : an ending value step (optional, number) : a step size

Returns:

An iterator of values less than end where the values are equal to start+step*n where n is 0, 1, 2, … This function works like the Python range function.

relu

relu (x, alpha, max_value, threshold)

Args:

x (array_like) : array alpha : Slope of negative region, scalar default is 0.0 max_value : Saturation threshold, scalar threshold : Threshold for thresholded activations, scalar default is 0.0

Returns:

An array with the elements of a clipped between 0 and max_value where values > threshold and alpha * ( a - threshold ) elsewhere.”

repeat

repeat (a, repeats, axis)

Args:

a (array)a scalar, a vector, a

matrix or a tensor

repeats (integer or a vector of integers)The number of

repetitions for each element. repeats is broadcasted to fit the shape of the given axis.

axis (optional, integer): an axis to repeat along. By default,

flattened input is used.

Returns:

Repeated array which has the same shape as a, except along the given axis. In case of no axis for matrices flatten result is returned

reshape

reshape (a, newshape)

Args:

a (array_like) : input array newshape (integer or tuple of integers): The new shape should be

compatible with the original shape (number of elements in both arrays are the same). If an integer, then the result will be a 1-D array of that length. The last parameter of the newshape can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

Returns:

Returns a new shape to an array without changing its data.”

resize_images

resize_images (a)

Args:

a (array_like) : input 4d array height_factor (integer) : enlargement factor for height width_factor (integer) : enlargement factor for width interpolation (string) : interpolation type, “bilinear” or

“nearest”

Returns:

Returns a resized version of the array with height_factor and width_factor using the specified interpolation .

retile_d

retile_d (a, tiling_type, intersection, numtiles, new_tiling)

Args:

a (array): a distributed array. A vector or a matrix. tiling_type (string, optional): defaults to sym which is a

balanced way of tiling among all localities. Other options are page (at least 3d array), row, column or user tiling types. If an intersection is given, retile produces tiles that have overlapped parts. In the user mode, using new_tiling, tiles are specified with their spans.

intersection (int or tuple of ints, optional): the size of

overlapped part on each dimension. If an integer is given, that would be the intersection length on all dimensions that are tiled. The middle parts get to have two intersections, one with the tile before it and one with the tile after it. In the user mode, intersection cannot be used.

numtiles (int, optional): number of tiles of the returned array

If not given it sets to the number of localities in the application.

new_tiling (list, optional): a new tiling specification for the

current locality that is specified only for the user mode E.g. for a matrix we can have: list(“tile”, list(“columns”, 0, 2), list(“rows”, 0, 2)) or list(“args”, list(“locality”, 0, 4),

list(“tile”, list(“columns”, 0, 2), list(“rows”, 0, 2)))

Returns:

A retiled array according to the tiling type on numtiles localities The returned array can contain overlapped parts

separable_conv1d

separable_conv1d (x, depthwise_kernel, pointwise_kernel, padding, strides,)

dilation_rate

Args:

x (array) : a stream of 3d data: batch, input_length, in_channels depthwise_kernel (array) : a 3d filter which dimensions are:

filter_length, depth_in_channels, depth_out_channels

pointwise_kernel (array)a 3d filter which dimensions are: 1,

point_in_channels, point_out_channels. point_in_channels should be depth_in_channels * depth_out_channels

padding (optional, string)padding mode, valid by default. It

can be either valid or same. vaild means no padding. same results the output with the same shape as original array

in case of unit strides.

strides (optional, integer)the step to apply convolution over

array. It sets to 1 by default.

dilation_rate (optional, integer)indicates the dilation rate,

the rate to sample the array in each step of convolution, 1 by default.

Returns:

1D convolution with separable filters

set_seed_action

set_seed_action (seed)

Args:

seed (int) : the seed of a random number generator

Returns:

shape

shape (a, dim)

Args:

a (object): an array of arbitrary dimensions dim (optional, int): the dimension to get the size of

Returns:

Without the optional argument, it returns a list of integers corresponding to the size of each dimension of the array a. If the optional dim argument is supplied, then the size for that dimension is returned as an integer. If the supplied array is distributed, the shape is calculated on the current locality.

shape_d

shape_d (a, dim)

Args:

a (object): a distributed array of arbitrary dimensions dim (optional, int): the dimension to get the size of

Returns:

Without the optional argument, it returns a list of integers corresponding to the size of each dimension of the array a on all localities. If the optional dim argument is supplied, then the size for that dimension of the whole array is returned as an integer.

shuffle

shuffle (args)

Args:

args (list) : a list of values

Returns:

A shuffled version of the list. Note that args itself will be ” shuffled by this call.

sigmoid

sigmoid (a)

Args:

a (array_like) : input array

Returns:

Returns an array of the same shape which is the calculated based on the mathematical function having a characteristic “S”-shaped curve or ‘sigmoid curve’

size

size (a)

Args:

a (array type): array to extract the size for

Returns:

Size of array (number of elements in the array).

slice

slice (v, ind)

Args:

v (list) : a list to take a slice from ind (int or list) : index or slice range

Returns:

If ind is an integer, this operation returns an element of the list. If it is negative, indexing is done from the back of the list. Alternatively, ind may consist of a list of values which serve as the start, stop, and (optionally) step of a Python range. In this case, the return value is a new list with the values of v described by the range.

slice_column

slice_column (v, ind)

Args:

v (list) : a list to take a slice from ind (int or list) : index or slice range

Returns:

If ind is an integer, this operation returns an element of the list. If it is negative, indexing is done from the back of the list. Alternatively, ind may consist of a list of values which serve as the start, stop, and (optionally) step of a Python range. In this case, the return value is a new list with the values of v described by the range.

slice_column_d

slice_column_d (v, ind)

Args:

v (list) : a list to take a slice from ind (int or list) : index or slice range

Returns:

If ind is an integer, this operation returns an element of the list. If it is negative, indexing is done from the back of the list. Alternatively, ind may consist of a list of values which serve as the start, stop, and (optionally) step of a Python range. In this case, the return value is a new list with the values of v described by the range.

slice_page

slice_page (v, ind)

Args:

v (list) : a list to take a slice from ind (int or list) : index or slice range

Returns:

If ind is an integer, this operation returns an element of the list. If it is negative, indexing is done from the back of the list. Alternatively, ind may consist of a list of values which serve as the start, stop, and (optionally) step of a Python range. In this case, the return value is a new list with the values of v described by the range.

slice_row

slice_row (v, ind)

Args:

v (list) : a list to take a slice from ind (int or list) : index or slice range

Returns:

If ind is an integer, this operation returns an element of the list. If it is negative, indexing is done from the back of the list. Alternatively, ind may consist of a list of values which serve as the start, stop, and (optionally) step of a Python range. In this case, the return value is a new list with the values of v described by the range.

slice_row_d

slice_row_d (v, ind)

Args:

v (list) : a list to take a slice from ind (int or list) : index or slice range

Returns:

If ind is an integer, this operation returns an element of the list. If it is negative, indexing is done from the back of the list. Alternatively, ind may consist of a list of values which serve as the start, stop, and (optionally) step of a Python range. In this case, the return value is a new list with the values of v described by the range.

softmax

softmax (a, axis)

Args:

a (array_like) : input array axis (optional, integer): an axis to softmax along. The

default is the last axis (axis == -1) of an array. Axis is effective for >1d arrays.

Returns:

Returns an array of the same shape which is the normalized exponential function of the given array. The resulting array consists of real values in the range (0..1], which add up to 1 in direction of the given axis

softplus

softplus (a)

Args:

a (array_like) : input array

Returns:

Returns an array of the same shape which is the the differential surrogate of the input and is defined as f(x) = ln(1 + e^x). Both the ReLU and Softplus are largely similar, except near 0 where the Softplus is enticingly smooth and differentiable.

softsign

softsign (a)

Args:

a (array_like) : input array

Returns:

Returns an array of the same shape which is defined as f(x) = 1/(1+abs(x).

sort

sort (a, axis, kind, order)

Args:

a (array_like) : input array axis (optional, int) : axis along which to sort. If None, array is

flattened before sorting. Default is -1.

kind (optional, string) : sorting algorithm, default is “quicksort” oredr (optional, string or list of string) : specifies which fields to

compare first, second, etc.

Returns:

The sorted array.”

spatial_2d_padding

spatial_2d_padding (x, padding)

Args:

x (array_like) : input 4d array padding (optional, a tuple of two tuples): the first tuple contains

two integers which indicate number of pages to pad on front and rear respectively. The second tuple also contains two integers that indicate number of rows to pad on the top and bottom of the data. The default is ((1,1),(1,1)).

Returns:

Pads the second and third dimensions of a 4d array with zeros

squeeze

squeeze (a, axis)

Args:

a (array) : a scalar, vector, matrix, tensor or a quatern axis (optional, integer): an axis to squeeze along. If an axis is

selected with shape entry greater than one, an error is raised.

Returns:

Remove single-dimensional entries from the shape of an array

stack

stack (args, axis, dtype)

Args:

*args (list, optional) : a list of array-like objects axis (int, optional) : the axis along which to stack input

values, the default value is ‘0’

dtype (optional, string)the data-type of the returned array,

defaults to dtype of input arrays.

Returns:

A joined sequence of array-like objects along a new axis.

std

std (arg, axis, keepdims, initial, dummy_, dtype)

Args:

arg (array of numbers) : the input values axis (optional, integer) : a axis to sum along keepdims (optional, boolean) : keep dimension of input dummy_ (nil) : unused dtype (optional, string) : the data-type of the returned array,

defaults to dtype of input array.

Returns:

The standard deviation of all values along the specified axis.

store

store (var, value)

Update the definition of variable var with value value. This primitive is used to implement the assignment operator. Note that the variable should first be created with define. Args:

var (symbol) : a variable to be defined value (expression) : a value to assign

Returns:

string

string (args)

Args:

*args (object list) : any objects

Returns:

A string created by concatenating the string representations of the objects in args.

sum

sum (v, axis, keepdims, initial, dtype)

Args:

v (vector or matrix) : a vector or matrix axis (optional, integer): a axis to sum along keepdims (optional, boolean): keep dimension of input initial (optional, scalar): The starting value for the sum dtype (optional, string) : the data-type of the returned array,

defaults to dtype of input array.

Returns:

The sum of all values along the specified axis.

switch

switch (condition, then_expression, else_expression)

Args:

condition (an array) : a tensor then_expression (an array) : either a tensor, or a callable

that returns a tensor.

else_expression (an array)either a tensor, or a callable

that returns a tensor.

Returns:

The selected tensor based on each element of condition. Note that both then_expression and else_expression should be symbolic tensors of the same shape. Condition cannot have a bigger rank than then_expression

tensordot

tensordot (a, b, axes)

Args:

a (array) : a vector, matrix or a tensor b (array) : a vector, matrix or a tensor axes(optional, integer or tuple of integers): if a scalar N, sum

over the last N axes of a and the first N axes of b in order. The sizes of the corresponding axes must match. If given (axes_a,axes_b), sum the products of two arrays elements (components) over the axes specified by a_axes and b_axes. The default is 2 (scalar axis).

Returns:

The tensor dot product along specified axes for arrays>=1-D.

tile

tile (a, reps)

Args:

a (array_like) : input array reps (integer or tuple of integers): Number of repetitions of

a along each axis.

Returns:

Constructs an array by repeating a, the number of times given by reps.

timer

timer (arg, done)

This primitive allows to measure the execution time of the embedded expression ‘arg’ and reports it to the supplied reporting function ‘done’.

Args:

arg (expression) : the operation to measure the execution time for done (function) : a function that will be called with the measured time

Returns:

whatever the evaluation of ‘arg’ returns

transpose

transpose (arg, axes)

Args:

arg (arr) : an array axes (optional, integer or a vector of integers) : By default,

reverse the dimensions, otherwise permute the axes according to the values given.

Returns:

The transpose of arg. If axes are provided, it returns arg with its axes permuted.

transpose_d

transpose_d (arg, axes)

Args:

arg (arr) : an array axes (optional, integer or a vector of integers) : By default,

reverse the dimensions, otherwise permute the axes according to the values given.

Returns:

The transpose of arg. If axes are provided, it returns arg with its axes permuted.

tuple_slice

tuple_slice (v, ind)

Args:

v (list) : a list to take a slice from ind (int or list) : index or slice range

Returns:

If ind is an integer, this operation returns an element of the list. If it is negative, indexing is done from the back of the list. Alternatively, ind may consist of a list of values which serve as the start, stop, and (optionally) step of a Python range. In this case, the return value is a new list with the values of v described by the range.

unique

unique (a, axis)

Args:

a (array_like) : input array axis (optional, int): which axis of a to use

Returns:

The sorted unique elements of an array.”

var

var (arg, axis, keepdims, initial, dummy_, dtype)

Args:

arg (array of numbers) : the input values axis (optional, integer) : a axis to sum along keepdims (optional, boolean) : keep dimension of input dummy_ (nil) : unused dtype (optional, string) : the data-type of the returned array,

defaults to dtype of input array.

Returns:

The statistical variance of all values along the specified axis.

vsplit

vsplit (args)

Args:

*args (m - matrix or column vector, N - number of blocks)

Returns:

An N by 1 matrix of vertical partitions of m

vstack

vstack (args, dtype)

Args:

*args (list, optional) : a list of array-like objects dtype (optional, string) : the data-type of the returned array,

defaults to dtype of input arrays.

Returns:

A vertically (row wise) stacked sequence of array-like objects

where

where (cond, var, val)

Args:

cond (boolean expression): a condition to apply var (matrix, optional): a matrix (used if cond is true) val (matrix, optional): a value to supply when cond is false

Returns:

A new matrix in which cells in matrix var that have values that do not match cond are replaced with value val.

Note:

Either both of or none of var and val can be provided. If none are provided, then where is equivalent to cond.nonzero().

while

while (cond, block)

Args:

cond (boolean expression): if it evaluates to True,

execute the loop again.

block (statement) : code to execute as long as cond is true.

Returns:

The value returned from the last iteration, nil otherwise.