libpymath.matrix package

Submodules

libpymath.matrix.matrix module

class libpymath.matrix.matrix.Matrix(*args, **kwargs)

Bases: object

T

See Matrix.transposed()

Returns:Return the transpose of a matrix
cols

The number of columns of the matrix

Type:return
copy()

Return an exact copy of a matrix

Returns:Copied matrix
dot(other)

Compute the matrix-matrix product with another matrix

Parameters:other – Matrix to compute matrix product with
Returns:Result of matrix product calculation
dtype

The datatype of the matrix

Type:return
fill(fillType, *args)

Fill a matrix. Valid fills are:

SCALAR -> Fill with a single scalar value ASCENDING -> Fill a matrix with ascending values, starting with 0 DESCENDING -> Fill a matrix with descending values, starting from (rows * cols) - 1 RANDOM -> Fill a matrix with random values between a given range (defaults to [-1, 1|)

Parameters:
  • fillType – Method to use when filling the matrix
  • args – Some fill methods accept parameters
Returns:

None

fillAscending()

See Matrix.map(ASCENDING)

Returns:None
fillDescending()

See Matrix.map(DESCENDING)

Returns:None
fillRandom(_min=None, _max=None)

See Matrix.map(RANDOM)

Returns:None
fillScalar(x)

See Matrix.map(SCALAR)

Parameters:x – Scalar value to fill with
Returns:None
map(mapType)

Apply a function to every element of the matrix.

Valid functions are: SIGMOID TANH RELU LEAKY_RELU

D_SIGMOID D_TANH D_RELU D_LEAKY_RELU

Parameters:mapType – Function to map with
Returns:None
mapped(mapType)

See Matrix.map()

Parameters:mapType – Function to map with
Returns:Mapped matrix
mean()
reshape(nr, nc)

Reshape a matrix by adjusting the rows and columns.

Parameters:
  • nr – New rows
  • nc – New columns
Returns:

None

reshaped(nr, nc)

Reshape a matrix by adjusting the rows and columns and return the result.

Parameters:
  • nr – New rows
  • nc – New columns
Returns:

Reshaped matrix

rows

The number of rows of the matrix

Type:return
shape

The shape of the matrix in the form (rows, columns)

Type:return
sum()
threads

The number of threads the matrix is using

Type:return
toList()

Convert a Matrix into a 2d Python list

Returns:2d Python list
transpose()

Transpose a matrix inplace.

Returns:None
transposed()

See Matrix.transpose()

Returns:Return the transpose of a matrix

Module contents

Copyright 2020 Toby Davis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.