<jupyter_start><jupyter_text><jupyter_code>import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt


model = tf.keras.applications.vgg16.VGG16(include_top=False, classes=10, input_shape = (32,32,3))

(X_train, y_train), (X_test, y_test) = tf.keras.datasets.cifar10.load_data()

X_train = tf.keras.applications.vgg16.preprocess_input(X_train)
X_test = tf.keras.applications.vgg16.preprocess_input(X_test)
y_train = tf.keras.utils.to_categorical(y_train)
y_test = tf.keras.utils.to_categorical(y_test)


model.trainable = False
input_layer = model.input
x = model(input_layer)
x = tf.keras.layers.Flatten()(x)
x = tf.keras.layers.Dense(256, activation = 'relu')(x)
x = tf.keras.layers.Dense(10, activation = 'softmax')(x)
 
new_model = tf.keras.models.Model(inputs = input_layer, outputs = x)
new_model.summary()
new_model.compile(loss ='categorical_crossentropy', optimizer = 'adam', metrics = ['acc'])

history = new_model.fit(X_train, y_train, validation_split = 0.1, epochs = 5)

new_model.evaluate(X_test, y_test)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13896713615023473, 'fraction_numerical': 0.023474178403755867, 'mean_word_length': 6.507042253521127, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '487622', 'license': 'MIT', 'n_tokens_mistral': 446, 'n_tokens_neox': 425, 'n_words': 67, 'path': 'lec6_transfer_learning/VGG19_CIFAR10_transfer_learning.ipynb', 'repo_name': 'ChihabEddine98/DL_course', 'size': '1065'}