Skip to content

Commit

Permalink
Upgrade TensorFlow version to v2.16.1 (#2282)
Browse files Browse the repository at this point in the history
* Upgrade TensorFlow version to v2.16.1

Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>

* Replace deprecated ImageDataGenerator with new data augmentation approach

Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>

---------

Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
  • Loading branch information
tenzen-y committed Apr 2, 2024
1 parent 8629a3c commit 9680b8c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
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),
])

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

0 comments on commit 9680b8c

Please sign in to comment.