I want to convert this composite model with this hierarchy into the individual Keras ops so that it can be converted to another format.
KWSTransformer(tf.keras.Model)
ConvolutionBlock(tf.keras.layers.Layer)
# coding=utf-8
# Copyright (c) 2021, Arm Limited and Contributors.
# SPDX-License-Identifier: Apache-2.0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Vision transformer implementation based on https://github.com/tuvovan/Vision_Transformer_Keras/blob/master/vit.py
import tensorflow as tf
import tensorflow_addons as tfa
from tensorflow.keras.layers import (
Dense,
This file has been truncated. show original
Is that possible to do automatically? You can get the nodes and connectivity of KWSTransformer using KWSTransformer.layers[n].outbound_nodes. But only for non-composite layers. There seems to be no way to get the underlying nodes of ConvolutionBlock?