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

Upgrade TensorFlow version to v2.16.1 #2282

Merged
merged 2 commits into from
Apr 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ psutil==5.9.4
rfc3339>=6.2
grpcio>=1.41.1
googleapis-common-protos==1.6.0
tensorflow==2.13.0
tensorflow==2.16.1
protobuf<=3.20.3
2 changes: 1 addition & 1 deletion cmd/suggestion/nas/enas/v1beta1/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
grpcio>=1.41.1
googleapis-common-protos==1.6.0
cython>=0.29.24
tensorflow==2.13.0
tensorflow==2.16.1
protobuf<=3.20.3
17 changes: 10 additions & 7 deletions examples/v1beta1/trial-images/enas-cnn-cifar10/RunTrial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from keras.datasets import cifar10
from ModelConstructor import ModelConstructor
from tensorflow.keras.utils import to_categorical
from keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.layers import RandomFlip, RandomTranslation, Rescaling
import tensorflow as tf
import argparse

Expand Down Expand Up @@ -76,18 +76,21 @@
y_train = to_categorical(y_train)
y_test = to_categorical(y_test)

augmentation = ImageDataGenerator(
width_shift_range=0.1,
height_shift_range=0.1,
horizontal_flip=True)
augmentation = tf.keras.Sequential([
Rescaling(1./255),
RandomFlip('horizontal'),
RandomTranslation(height_factor=0.1, width_factor=0.1),
])
Comment on lines -79 to +83
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a deprecated approach and moved to `tensorflow.keras.preprocessing.image.

Traceback (most recent call last):
  File "/opt/enas-cnn-cifar10/RunTrial.py", line 19, in <module>
    from keras.preprocessing.image import ImageDataGenerator
ImportError: cannot import name 'ImageDataGenerator' from 'keras.preprocessing.image' (/usr/local/lib/python3.11/site-packages/keras/preprocessing/image/__init__.py)

https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator

So, I introduced the recommended approach.


train_dataset = tf.data.Dataset.from_tensor_slices((x_train, y_train))
train_dataset = train_dataset.map(lambda x, y: (augmentation(x, training=True), y))
# TODO: Add batch size to args
aug_data_flow = augmentation.flow(x_train, y_train, batch_size=128)
train_dataset = train_dataset.batch(128)

print(">>> Data Loaded. Training starts.")
for e in range(num_epochs):
print("\nTotal Epoch {}/{}".format(e + 1, num_epochs))
history = test_model.fit(aug_data_flow,
history = test_model.fit(train_dataset,
steps_per_epoch=int(len(x_train) / 128) + 1,
epochs=1, verbose=1,
validation_data=(x_test, y_test))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scipy>=1.7.2
tensorflow==2.13.0
tensorflow==2.16.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
tensorflow==2.13.0
tensorflow==2.16.1
Loading