'How can i read a part of a Tensor?

I have the below function:

def dice_coef(y_true, y_pred, smooth=1):
intersection = K.sum(K.abs(y_true * y_pred), axis=-1)
return (2 * intersection + smooth) / (K.sum(K.square(y_true), -1) + 
K.sum(K.square(y_pred), -1) + smooth)

first I can't understand why Keras backend is used for the calculations. and in the second place, the result of this function is something like below:

<tf.Tensor: shape=(), dtype=float64, numpy=0.19487999309893356>

but I just one a simple result. how can I solve this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source