This repository was archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy path__init__.py
More file actions
44 lines (37 loc) · 1.43 KB
/
__init__.py
File metadata and controls
44 lines (37 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""Enables dynamic setting of underlying Keras module.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import pkg_resources
_KERAS_BACKEND = None
_KERAS_UTILS = None
def set_keras_submodules(backend, utils):
# Deprecated, will be removed in the future.
global _KERAS_BACKEND
global _KERAS_UTILS
_KERAS_BACKEND = backend
_KERAS_UTILS = utils
def get_keras_submodule(name):
# Deprecated, will be removed in the future.
if name not in {'backend', 'utils'}:
raise ImportError(
'Can only retrieve "backend" and "utils". '
'Requested: %s' % name)
if _KERAS_BACKEND is None:
raise ImportError('You need to first `import keras` '
'in order to use `keras_preprocessing`. '
'For instance, you can do:\n\n'
'```\n'
'import keras\n'
'from keras_preprocessing import image\n'
'```\n\n'
'Or, preferably, this equivalent formulation:\n\n'
'```\n'
'from keras import preprocessing\n'
'```\n')
if name == 'backend':
return _KERAS_BACKEND
elif name == 'utils':
return _KERAS_UTILS
__version__ = pkg_resources.get_distribution('keras_preprocessing').version