<reponame>jpmarques19/tensorflwo-test
# Third Party
import tensorflow as tf
from tensorflow.keras import utils
from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.datasets import cifar10
from tensorflow.keras.preprocessing.image import ImageDataGenerator

num_classes = 10

(x_train, y_train), (x_test, y_test) = cifar10.load_data()
y_train = utils.to_categorical(y_train, num_classes)
y_test = utils.to_categorical(y_test, num_classes)

# Define simple image model
strategy = tf.distribute.MirroredStrategy()

with strategy.scope():
    model = ResNet50(weights=None, input_shape=(32, 32, 3), classes=10)
    model.compile(optimizer="adam", loss="categorical_crossentropy")

datagen = ImageDataGenerator(
    featurewise_center=True,
    featurewise_std_normalization=True,
    rotation_range=20,
    width_shift_range=0.2,
    height_shift_range=0.2,
    horizontal_flip=True,
)

# compute quantities required for featurewise normalization
# (std, mean, and principal components if ZCA whitening is applied)
datagen.fit(x_train)
# fits the model on batches with real-time data augmentation:
model.fit(datagen.flow(x_train, y_train, batch_size=2048), steps_per_epoch=32, epochs=1)

# Third Party
import tensorflow as tf
from tensorflow.keras import utils
from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.datasets import cifar10
from tensorflow.keras.preprocessing.image import ImageDataGenerator

num_classes = 10

(x_train, y_train), (x_test, y_test) = cifar10.load_data()
y_train = utils.to_categorical(y_train, num_classes)
y_test = utils.to_categorical(y_test, num_classes)

# Define simple image model
strategy = tf.distribute.MirroredStrategy()

with strategy.scope():
    model = ResNet50(weights=None, input_shape=(32, 32, 3), classes=10)
    model.compile(optimizer="adam", loss="categorical_crossentropy")

datagen = ImageDataGenerator(
    featurewise_center=True,
    featurewise_std_normalization=True,
    rotation_range=20,
    width_shift_range=0.2,
    height_shift_range=0.2,
    horizontal_flip=True,
)

# compute quantities required for featurewise normalization
# (std, mean, and principal components if ZCA whitening is applied)
datagen.fit(x_train)
# fits the model on batches with real-time data augmentation:
model.fit(datagen.flow(x_train, y_train, batch_size=2048), steps_per_epoch=32, epochs=1)
# Third Party # Define simple image model # compute quantities required for featurewise normalization # (std, mean, and principal components if ZCA whitening is applied) # fits the model on batches with real-time data augmentation: