keras-team / keras-applications

Reference implementations of popular deep learning models.
Other
2k stars 913 forks source link

How to instantiate a Model with global variable models #136

Closed gitfourteen closed 4 years ago

gitfourteen commented 4 years ago

In InceptionV3, can not figure out why this line can create a model model = models.Model(inputs, x, name='inception_v3')

and when trace back to this function get_submodules_from_kwargs(kwargs), it ends abruptly without further reference. Would you please advise? thank you!

taehoonlee commented 4 years ago

@gitfourteen, The line you mentioned is one of the functional APIs. Please refer to the documents.

The decorator puts keras modules into kwargs, and then the function gets keras modules from kwargs.

gitfourteen commented 4 years ago

@taehoonlee , thanks for your reply. I did not notice at first that the original import is under tensorflow environment: from tensorflow.keras.applications.inception_v3 import InceptionV3

But still I looked for models.Model(...) in keras-team/keras in vain.

The reference chain for Model instantiation in tensorflow are like this: module.Module --> base_layer.Layer --> network.Network --> engine.training.Model --> models.py --> __init__.py --> @keras_modules_injection --> InceptionV3