<jupyter_start><jupyter_text>Loading CIFAR 10 dataset and preprocessing it<jupyter_code>num_classes = 10

(x_train, y_train), (x_test, y_test) =  tf.keras.datasets.cifar10.load_data()

# Enabling One Hot Encoding
y_test = np_utils.to_categorical(y_test, num_classes)

# Changing input image datatype to float
x_test = x_test.astype('float32')

# Normalizaig data
x_test /= 255
x_test = x_test.reshape([10000, 3072])

numTest = 10000<jupyter_output><empty_output><jupyter_text>Importing the int8 precision model and float32 model and measuring latency on CIFAR-10 dataset<jupyter_code>interpreter = tf.lite.Interpreter(model_path="C://users/navee/LeNet-300-100_CIFAR10/LeNet_int8_model_CIFAR-10.tflite")
interpreter.allocate_tensors()
input_index = interpreter.get_input_details()[0]["index"]
start = time.time()
count = 0
for i in range(numTest):
    input_data = np.array(x_test[i].reshape([1, 3072]), dtype = np.float32)
    interpreter.set_tensor(input_index, input_data)
    interpreter.invoke()
    output_details = interpreter.get_output_details()
    output_index = output_details[0]['index']
    output_data = interpreter.get_tensor(output_index)
    pred_model = np.argmax(output_data)
    pred_data = np.argmax(y_test[i])
    if(pred_model == pred_data):
        count += 1
end = time.time()
print("Inference Time = ", (end - start)) 
print("Accuracy = ", str((count / numTest) * 100))
interpreter = tf.lite.Interpreter(model_path="C://users/navee/LeNet-300-100_CIFAR10/LeNet_float32_model_CIFAR-10.tflite")
interpreter.allocate_tensors()
input_index = interpreter.get_input_details()[0]["index"]
start = time.time()
count = 0
for i in range(numTest):
    input_data = np.array(x_test[i].reshape([1, 3072]), dtype = np.float32)
    interpreter.set_tensor(input_index, input_data)
    interpreter.invoke()
    output_details = interpreter.get_output_details()
    output_index = output_details[0]['index']
    output_data = interpreter.get_tensor(output_index)
    pred_model = np.argmax(output_data)
    pred_data = np.argmax(y_test[i])
    if(pred_model == pred_data):
        count += 1
end = time.time()
print("Inference Time = ", (end - start)) 
print("Accuracy = ", str((count / numTest) * 100))<jupyter_output>Accuracy = 43.57
{'fraction_non_alphanumeric': 0.1311329170383586, 'fraction_numerical': 0.03791257805530776, 'mean_word_length': 5.39031339031339, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '377603', 'license': 'MIT', 'n_tokens_mistral': 877, 'n_tokens_neox': 813, 'n_words': 140, 'path': 'Quantization/CIFAR-10/LeNet-300-100/Quantization_LeNet-300-100_CIFAR-10_Evaluation.ipynb', 'repo_name': 'Naveen-Lalwani/18663-Study-of-Neural-Network-Compression-Techniques', 'size': '2242'}