Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid import tensorflow directly #18655

Merged
merged 2 commits into from
Oct 21, 2023
Merged
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
5 changes: 2 additions & 3 deletions keras/distribution/distribution_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

import numpy as np

# TF is used for dataset sharding.
import tensorflow as tf

from keras.api_export import keras_export
from keras.backend import KerasTensor
from keras.backend import distribution_lib
Expand Down Expand Up @@ -426,6 +423,8 @@ def get_tensor_layout(self, path):
return None

def distribute_dataset(self, dataset):
from keras.utils.module_utils import tensorflow as tf

if not isinstance(dataset, tf.data.Dataset):
raise ValueError(
"Only `tf.data.Dataset` is supported for "
Expand Down