This repository was archived by the owner on Nov 3, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +4
-50
lines changed
Expand file tree Collapse file tree 2 files changed +4
-50
lines changed Original file line number Diff line number Diff line change 1010_KERAS_UTILS = None
1111
1212
13- def set_keras_submodules (backend = None ,
14- layers = None ,
15- models = None ,
16- utils = None ,
17- engine = None ):
18- # Deprecated, will be removed in the future.
19- global _KERAS_BACKEND
20- global _KERAS_LAYERS
21- global _KERAS_MODELS
22- global _KERAS_UTILS
23- _KERAS_BACKEND = backend
24- _KERAS_LAYERS = layers
25- _KERAS_MODELS = models
26- _KERAS_UTILS = utils
27-
28-
29- def get_keras_submodule (name ):
30- # Deprecated, will be removed in the future.
31- if name not in {'backend' , 'layers' , 'models' , 'utils' }:
32- raise ImportError (
33- 'Can only retrieve one of "backend", '
34- '"layers", "models", or "utils". '
35- 'Requested: %s' % name )
36- if _KERAS_BACKEND is None :
37- raise ImportError ('You need to first `import keras` '
38- 'in order to use `keras_applications`. '
39- 'For instance, you can do:\n \n '
40- '```\n '
41- 'import keras\n '
42- 'from keras_applications import vgg16\n '
43- '```\n \n '
44- 'Or, preferably, this equivalent formulation:\n \n '
45- '```\n '
46- 'from keras import applications\n '
47- '```\n ' )
48- if name == 'backend' :
49- return _KERAS_BACKEND
50- elif name == 'layers' :
51- return _KERAS_LAYERS
52- elif name == 'models' :
53- return _KERAS_MODELS
54- elif name == 'utils' :
55- return _KERAS_UTILS
56-
57-
5813def get_submodules_from_kwargs (kwargs ):
5914 backend = kwargs .get ('backend' , _KERAS_BACKEND )
6015 layers = kwargs .get ('layers' , _KERAS_LAYERS )
Original file line number Diff line number Diff line change 2929def keras_modules_injection (base_fun ):
3030
3131 def wrapper (* args , ** kwargs ):
32- if hasattr (keras_applications , 'get_submodules_from_kwargs' ):
33- kwargs ['backend' ] = backend
34- kwargs ['layers' ] = layers
35- kwargs ['models' ] = models
36- kwargs ['utils' ] = utils
32+ kwargs ['backend' ] = backend
33+ kwargs ['layers' ] = layers
34+ kwargs ['models' ] = models
35+ kwargs ['utils' ] = utils
3736 return base_fun (* args , ** kwargs )
3837 return wrapper
3938
You can’t perform that action at this time.
0 commit comments