You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Keras interface works fine but I had to change the Binary Encoding.
TensorFlow’s Graph Mode relies on Symbolic Tensors, which act as placeholders without actual data during initial model checks. When using model.fit, TensorFlow first uses these Symbolic Tensors to traverse and verify the computation graph, ensuring compatibility across all operations. Only after this validation process, when the graph structure is confirmed as sound, does TensorFlow pass real data through the model to perform actual training. This approach allows TensorFlow to optimize and catch issues before handling real inputs.
Therefore, we have the following problems (probably more) when dealing with Symbolic Tensors:
We cannot use NumPy functions on Symbolic Tensors;
We cannot access data contained in Symbolic Tensors (because they are empty);
We cannot iterate over Symbolic Tensors (because they are empty);
We cannot use "if" statements if Symbolic Tensors are involved;
We need to work around these problems by using native TensorFlow functions.
For instance, instead of an "if" statement we must use tf.cond.
However, the issue that I have encountered with the Binary Encoding (which has forced me to redefine this encoding) could be a sign of a deeper problem: we might need to define each encoding (or every other component of the QuantumModel) depending on the frontend that we use.
This is due to the fact that Symbolic Tensors force us to use native TensorFlow functions, that could be not compatible with PyTorch.
The text was updated successfully, but these errors were encountered:
You can force eager execution with run_eagerly=True in model.compilehttps://www.tensorflow.org/api_docs/python/tf/keras/Model#run_eagerly
This is probably not recommended for the sake of pure speed, but we could just do that for those layers that are problematic, at least for the moment.
The Keras interface works fine but I had to change the Binary Encoding.
TensorFlow’s Graph Mode relies on Symbolic Tensors, which act as placeholders without actual data during initial model checks. When using
model.fit
, TensorFlow first uses these Symbolic Tensors to traverse and verify the computation graph, ensuring compatibility across all operations. Only after this validation process, when the graph structure is confirmed as sound, does TensorFlow pass real data through the model to perform actual training. This approach allows TensorFlow to optimize and catch issues before handling real inputs.Therefore, we have the following problems (probably more) when dealing with Symbolic Tensors:
We need to work around these problems by using native TensorFlow functions.
For instance, instead of an "if" statement we must use
tf.cond
.However, the issue that I have encountered with the Binary Encoding (which has forced me to redefine this encoding) could be a sign of a deeper problem: we might need to define each encoding (or every other component of the QuantumModel) depending on the frontend that we use.
This is due to the fact that Symbolic Tensors force us to use native TensorFlow functions, that could be not compatible with PyTorch.
The text was updated successfully, but these errors were encountered: