<jupyter_start><jupyter_text>Creating image Recognition Model<jupyter_code>from tensorflow import keras
import tensorflow as tf
digit_mnist = keras.datasets.mnist
(x_train_full,y_train_full),(x_test,y_test) = digit_mnist.load_data()
import matplotlib.pyplot as plt
plt.imshow(x_train_full[11])
y_train_full[0]
x_train_full[0]
x_train_n = x_train_full/255.0
x_test_n = x_test/255.0
x_train_n[0]
len(x_train_n)
x_train,x_valid = x_train_n[:3000],x_train_n[3000:]
y_train,y_valid = y_train_full[:3000],y_train_full[3000:]
x_test = x_test_n
x_valid[0]
import pandas as pd
import numpy as np
np.random.seed(42)
tf.random.set_seed(42)
x_train.shape
model = keras.models.Sequential()
model.add(keras.layers.Flatten(input_shape = [28,28]))
model.add(keras.layers.Dense(200, activation = "relu"))
model.add(keras.layers.Dense(100, activation = "relu"))
model.add(keras.layers.Dense(10, activation = "softmax"))
model.summary()
import pydot
keras.utils.plot_model(model)
weights, biases = model.layers[1].get_weights()
weights.shape
biases.shape
model.compile(loss = "sparse_categorical_crossentropy",optimizer = "sgd",metrics = ["accuracy"])
model_history = model.fit(x_train,y_train, epochs = 60, validation_data=(x_valid,y_valid))
model_history.params
model_history.history
model.evaluate(x_test,y_test)
x_new = x_test[:3]
y_prob = model.predict(x_new)
y_prob.round(2)
y_prob_new = model.predict_classes(x_new)
y_prob_new
plt.imshow(x_test[2])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13233287858117326, 'fraction_numerical': 0.03547066848567531, 'mean_word_length': 8.525974025974026, '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': '630853', 'license': 'Apache-2.0', 'n_tokens_mistral': 632, 'n_tokens_neox': 591, 'n_words': 89, 'path': 'number_assignment_prediction.ipynb', 'repo_name': 'singhrau0/hand_written_digit_predictor', 'size': '1466'}