throws error

Hi, I tried using the following command

and gave the following error. It is used on the google’s collab jupyter notebook. Let me what could be the problem and solution to it.

TypeError Traceback (most recent call last)
in <cell line: 1>()
----> 1

/usr/local/lib/python3.10/dist-packages/keras/src/engine/ in op(self)
257 @property
258 def op(self):
→ 259 raise TypeError(
260 "Keras symbolic inputs/outputs do not "
261 "implement op. You may be "

TypeError: Keras symbolic inputs/outputs do not implement op. You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model.

Hi @Nagaraj_Trivedi, If you want to get the last layer operation you can use . The Output will be the layer name and its activation For example, If my model’s last layer was

#Output: dense/Softmax:0

Thank You!

It worked and got the output as
output_names =

Tried printing output_names and it displayed the below output

But after using this in the following statement gives this error

tf.compat.v1.graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), [output_names], variable_names_whitelist=None,

It gave below error

AssertionError Traceback (most recent call last)

in <cell line: 1>() ----> 1 tf.compat.v1.graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), [output_names], variable_names_whitelist=None, 2 variable_names_blacklist=None)

6 frames

/usr/local/lib/python3.10/dist-packages/tensorflow/python/framework/ in _assert_nodes_are_present(name_to_node, nodes) 196 “”“Assert that nodes are present in the graph.”“” 197 for d in nodes: → 198 assert d in name_to_node, “%s is not in graph” % d 199 200

AssertionError: dense_1/Softmax:0 is not in graph

Let me know what could be the problem. Is it due to using instead of actual Please clarify.

Hi @Nagaraj_Trivedi, tf.compact.v1 is deprecated in the 2.x version. In order to keep the weights constant you can save the trained model and load the saved model and make the model.trainable=False. Thank You.