Question: # Distance Calculation # # Create a tensor among the following types : float 3 2 , float 6 4 , complex 6 4 ,
# Distance Calculation
#
# Create a tensor among the following types : float float complex complex
# Mentioned link details the meaning of each variable :
# create two tensors of shape x
tensora tfconstant dtypetffloat name'template'
tensorb tfconstant dtypetffloat name'template'
# Calculating euclidean distance or the l norm.
euclediandistance tfnormtensora tensorb ord 'euclidean', axisNone, keepdimsNone
tfprintEuclidean distance:", euclediandistance
# Calculating the Manhattan distance
manhattandistance tfnormtensora tensorb ord axisNone, keepdimsNone
tfprintManhattan distance:", manhattandistance
# Calculating Euclidean Distance
def euclideandistancetensor tensor:
# implement your code below line
eucdistance
# your code ends here
return eucdistance
# Calculating Manhattan distance
def manhattandistancetensor tensor:
# implement your code below line
manhdistance
# your code ends here
return manhdistance
tfprintEuclidean distance:", euclideandistancetensora tensorb
tfprintManhattan distance:", manhattandistancetensora tensorb
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
