I have a multiheaded autoencoder that outputs both the encoded image(s) and the decoded image(s).
encoded_outputs = [encoder(input_layer) for input_layer in input_layers]
decoded_outputs = [decoder(encoded_output) for encoded_output in encoded_outputs]
autoencoder = Model(inputs=input_layer, outputs=[encoded_outputs, decoded_outputs])
I compiled it with loss = model_loss. This way, the encoded_outputs and decoded_outputs both had their respective losses. I think the problem is with the part that says "encoded_outputs, decoded_outputs = y_pred".:
def euclidean_distance_loss(latent_spaces):
...
return 1/average_distance
def model_loss(y_true, y_pred):
encoded_outputs, decoded_outputs = y_pred
loss_encoded = euclidean_distance_loss(encoded_outputs)
loss_decoded = tf.keras.losses.mean_squared_error(y_true, decoded_outputs)
return loss_encoded + loss_decoded
I tried to train it on a single sample with one step:
r = r.reshape(1,8,256,256,3)
autoencoder.fit(r, r, epochs=1, batch_size=1)
But it gave me an error, which I think is related to the loss function. I did some research and I think it is unable to access one of the loss functions, or the problem might be with the part that seperates y_pred into 2 parts:
OperatorNotAllowedInGraphError: in user code:
OperatorNotAllowedInGraphError: Iterating over a symbolic `tf.Tensor` is not allowed. You can attempt the following resolutions to the problem: If you are running in Graph mode, use Eager execution mode or decorate this function with @tf.function. If you are using AutoGraph, you can try decorating this function with @tf.function. If that does not work, then you may be using an unsupported feature or your source code may not be visible to AutoGraph.
The error message suggests a problem with the line encoded_outputs, decoded_outputs = y_pred within the model_loss function. The error specifically mentions an "OperatorNotAllowedInGraphError," indicating that iterating over a symbolic tf.Tensor is not allowed. I suspect there might be an issue with accessing one of the loss functions or with the structure of the y_pred output.
Any insights or suggestions on how to address this issue would be greatly appreciated.