<jupyter_start><jupyter_text>TensorFlow Keras CIFAR10 Example on Habana GaudiTMThis Jupyter Notebook example demonstrates how to train a simple neural network on Habana GaudiTM card. The neural network is built with Keras APIs, and trained with CIFAR10 dataset. We will clone Habana `Model-References` repository 0.15.4 branch to the current directory.<jupyter_code>import sys
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
from tensorflow.keras import datasets, layers, models

(train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data()
train_images, test_images = train_images / 255.0, test_images / 255.0
from model_def import get_model
model = get_model(input_shape=(32,32,3))<jupyter_output><empty_output><jupyter_text>Code changes to run model on Habana<jupyter_code>!git clone -b 0.15.4 https://github.com/HabanaAI/Model-References.git
sys.path.append('./Model-References')
from TensorFlow.common.library_loader import load_habana_module
load_habana_module()<jupyter_output><empty_output><jupyter_text>Train custom model on CIFAR10 dataset<jupyter_code>opt = tf.optimizers.Adam(0.001)

model.compile(loss=tf.losses.SparseCategoricalCrossentropy(),
              optimizer=opt,
              metrics=["accuracy"])
%%time
model.fit(train_images, train_labels, 
          epochs=20,
          batch_size=256,
          validation_data=(test_images, test_labels))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0916030534351145, 'fraction_numerical': 0.027064538514920196, 'mean_word_length': 5.706976744186046, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '29338', 'license': 'Apache-2.0', 'n_tokens_mistral': 493, 'n_tokens_neox': 460, 'n_words': 108, 'path': 'notebooks/1_CIFAR10_Jupyter_Notebook/tf_cifar.ipynb', 'repo_name': 'shashankprasanna/aws-dl1-workshop-2022', 'size': '1441'}