Professional Documents
Culture Documents
Basic Basic
Status Ongoing
GPU vs TPU:
Tensorflow 1
GPU is used to do parrallel task more efficiently than CPU and can be used for
image, video and natural language processing where TPU can be used to do the
multiplication of matrix upto hundred of TFLOPS (Trillion Floating Point Operations
per Second).
What is a tensor?
Tensor is a mathematical object or ndarray in which we represent a physical model
to the computer in the form of matrix. e.g. When we gives input to the model it
converts that input of image/video/voice into tensors (in numbers) which can be
easily understood by the neural network.
By default, TensorFlow creates tensors with either an int32 or float32 datatype.
The more it’s precise the more it takes space on memory.
224, 224 (the first 2 dimensions) are the height and width of the images in pixels.
32 is the batch size (the number of images a neural network sees at any one
time).
We can change the value of tensor created with tf.Variable() using assign() method.
Tensorflow 2
changeable =tf.Variable([7,3])
unchangeable = tf.constant([7,3])
changeable, unchangeable
changeable[0].assign(17)
unchangeable[0].assign(70) #We can't do this because it's constant
changeable
Tensors vs Arrays
The only difference b/w both of these are tensors can be run on GPUs. We can
reshape 3D, 4D... arrays or tensors into 1D by putting -1 inside reshape method e.g.
take a look at below code
[ [ 7, 8, 9],
[10, 11, 12]
]])
change_dim.ndim
change_dim.reshape(-1)
[ [ 7, 8, 9],
[10, 11, 12]
]])
tensor
tensor_new = tf.reshape(tensor,shape=(-1))
tensor_new
# For iterating through all the elements in a tensor we can use nditor method
for item in np.nditer(tensor):
print(item)
# Or we can do the long version of it.
for x in tensor:
for y in x:
for z in y:
print(z.numpy())
Tensorflow 3
will make it overfit by looking to the order of the dataset that’s why we need to shuffle
the dataset so that every image in it is in random order.
Tensor are the simple tensor which contain some numerical values.
SparseTensor is needed when we have an image which contain lots of dark pixel
which is detoned by zero so we simply mitigate those dark pixel denoted by zero
and take the actual values and their corresponding indices and shape which
reduce computation time of our GPU instead of calculating the zeros values
also.
Tensorflow 4
Hyperparameter Typical value
Tensorflow 5