I am trying to create my own loss function:

def custom_mse(y_true, y_pred):

tmp = 10000000000

a = list(itertools.permutations(y_pred))

for i in range(0, len(a)):

t = K.mean(K.square(a[i] - y_true), axis=-1)

if t < tmp :

tmp = t

return tmp

It should create permutations of predicted vector, and return the smallest loss.

"`Tensor` objects are not iterable when eager execution is not "

TypeError: `Tensor` objects are not iterable when eager execution is not enabled.

To iterate over this tensor use `tf.map_fn`.

error. I fail to find any source for this error. Why is this happening?

Thanks for the help.