print_numpy_matrix()

home > kero > Documentation

Print numpy matrix with nice indentation.

kero.utils.utils.py

def print_numpy_matrix(np_mat,formatting="%6.2f",no_of_space=20):
  return

Arguments/Return

np_mat,formatting String. The usual format for printing in python.

Default=”%6.2f”S

no_of_space Integer. Number of spaces from the left with which the matrix is indented.

Default=20

Example Usage 1

import kero.utils.utils as ut
import numpy as np

x=np.matrix(np.random.normal(size=(3,4)))
print("x = ")
print(x)
print("\nwith print_numpy_matrix(): ")
print("x = ")
ut.print_numpy_matrix(x,formatting="%6.5f",no_of_space=10)

whose output is

x =
[[ 1.61318393 -0.37102784 -0.89363802 -0.56962807]
[-0.08657515 1.20537268 -1.95176244 -1.84425267]
[-0.59647232 -0.96593909 1.02197755 0.39493434]]

with print_numpy_matrix():
x =
1.61318 -0.37103 -0.89364 -0.56963
-0.08658 1.20537 -1.95176 -1.84425
-0.59647 -0.96594 1.02198 0.39493

Example Usage 2

See Deep Learning and Neural Network with kero PART 1.

kero version: 0.6.2