Tuesday 19 November 2019

check shape of array in numpy and tensorflow

Numpy : its a python module/package to perform scientific computation on arrays.

How to install numpy package in anaconda

>> pip install  numpy

or

>> conda install numpy

To check if numpy package is  installed or not use

>> conda list
output :
>> numpy                     1.14.2

Once the package is installed you can import into you application

ex : import numpy

Basic numpy operation on Array :

>>> input = np.array([[1,2,3],[2,3,4]])
>>> input.shape
>>> (2, 3)


Ex : In digit recognition using tensorflow we can get shape

import tensorflow as tf
mnist = tf.keras.datasets.mnist
import numpy as np
print( tf.__version__)
(x_train, y_train),(x_test, y_test) = mnist.load_data()

print(x_train.shape);
>> (60000, 28, 28)
print( x_train[0].shape)
>> (28, 28) 


Note :
1. Tensorflow | keras| framework is used.
2. Mnist database for digit recognition