So by creating a new model with desired intermediate out works but by the same time, we repeat the same operation twice i.e the base model and its subset model. Next, we take the mid_faet and do some operation and get some output and lastly add them with tf.(). In the init method we define or create new self.mid_layer_model model that gives our desired output feature maps like this: mid_feat = self.mid_layer_model(inputs). So, currently, we have to build a new model from the base model based on our desired intermediate layer. Like this mid_x = SomeOperationLayer()(_layer(layer_name).output)īut it gives ValueError: Graph disconnected. But unlike building a model like this, here we simply want the intermediate output feature maps (from some inputs) of the base model forward manner and use it somewhere else and get some output. The issue is, here we've technically two models in a joint fashion. # building new model with the desired output layer of base model Self.base = DenseNet121(input_shape=self.dim) My concern here is, what to do if we need the intermediate output feature maps of these functional API models' inside call function. In model subclassing API, we can use these models. All the keras imagenet models are written with functional API (mostly). So, in this way we have one modified model. Imputed_model = tf.keras.Model(inputs=, outputs=base) Output_feat_maps = SomeOperationLayer()(model.get_layer(layer_name).output)īase = Add()() Layer_name = "conv1_block1" # for example Input = tf.keras.Input(shape=(size,size,3)) Likewise, if we get the intermediate layer's output feature maps of the parent model (or base model), and do some operation with it and get some output feature maps from this operation, then we can also impute this output feature maps back to the parent model. So, here we get two models, the intermediate_layer_model is the sub-model of its parent model. ![]() Intermediate_output = intermediate_layer_model(data) Outputs=model.get_layer(layer_name).output) ![]() In the keras doc, it says that if we want to pick the intermediate layer's output of the model (sequential and functional), all we need to do as follows: model =.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |