ValueError: Output tensors to a Model must be the output of a TensorFlow `Layer`

I have found a way to work around to solve the problem.
For anyone who encounters the same issue, you can use the Lambda layer to wrap your tensorflow operations, this is what I did:

from tensorflow.python.keras.layers import Lambda;

def norm(fc2):

    fc2_norm = K.l2_normalize(fc2, axis = 3);
    illum_est = tf.reduce_sum(fc2_norm, axis = (1, 2));
    illum_est = K.l2_normalize(illum_est);

    return illum_est;

illum_est = Lambda(norm)(fc2);

Leave a Comment