Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions kerastuner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@
from .tuners import Hyperband
from .tuners import RandomSearch

from .utils import check_tf_version
check_tf_version()

__version__ = '1.0.0'
15 changes: 14 additions & 1 deletion kerastuner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Keras Tuner utilities."""


from packaging.version import parse
import tensorflow as tf


Expand All @@ -27,3 +27,16 @@ def create_directory(path, remove_existing=False):
elif remove_existing:
tf.io.gfile.rmtree(path)
tf.io.gfile.makedirs(path)


def check_tf_version():
if parse(tf.__version__) < parse('2.0.0'):
raise ImportError(
f'The Tensorflow package version needs to be at least v2.0.0 \n'
f'for Keras Tuner to run. Currently, your TensorFlow version is \n'
f'v{tf.__version__}. Please upgrade with \n'
f'`$ pip install --upgrade tensorflow` -> GPU version \n'
f'or \n'
f'`$ pip install --upgrade tensorflow-cpu` -> CPU version. \n'
f'You can use `pip freeze` to check afterwards that everything is ok.'
)
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
author='The Keras Tuner authors',
author_email='[email protected]',
license='Apache License 2.0',
# tensorflow isn't a dependency because it would force the
# download of the gpu version or the cpu version.
# users should install it manually.
install_requires=[
'tensorflow>=2.0.0-beta1',
'packaging',
'future',
'numpy',
'tabulate',
Expand Down