<jupyter_start><jupyter_text><jupyter_code>import tensorflow as tf
import numpy as np
from tensorflow import keras
print(tf.__version__)
model = tf.keras.Sequential([keras.layers.Dense(units = 1, input_shape = [1])])
model.summary()
model.compile(optimizer = 'sgd', loss = 'mean_squared_error', metrics = ['accuracy'])
xs = np.array([-1.0,  0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)
ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)
model.fit(xs , ys, epochs = 100)
print(model.predict([10.0]))<jupyter_output>[[17.884777]]<jupyter_text>====================================================<jupyter_code>mnist = tf.keras.datasets.fashion_mnist
(training_images, training_labels),(test_images, test_labels) = mnist.load_data()
print(training_images.shape)
print(test_images.shape)
print(training_labels.shape)
print(test_labels.shape)
np.set_printoptions(linewidth = 300)
import matplotlib.pyplot as plt
plt.imshow(training_images[0])
print(training_labels[0])
print(training_images[0])
training_images = training_images / 255
test_images = test_images / 255
model = tf.keras.Sequential([tf.keras.layers.Flatten(),
                             tf.keras.layers.Dense(128, activation = tf.nn.relu),
                             tf.keras.layers.Dense(10, tf.nn.softmax)])
model.compile(optimizer = tf.optimizers.Adam(),
              loss = 'sparse_categorical_crossentropy',
              metrics = ['accuracy'])
model.fit(training_images, training_labels, epochs = 10)
model.summary()
1875 * 32
128*785
model.evaluate(test_images,test_labels)<jupyter_output><empty_output><jupyter_text>===============================================<jupyter_code>mnist = tf.keras.datasets.fashion_mnist
(training_images, training_labels), (test_images, test_labels) = mnist.load_data()
training_images = training_images.reshape(60000,28,28,1)
test_images = test_images.reshape(10000,28,28,1)
training_images = training_images / 255
test_images = test_images / 255
model = tf.keras.models.Sequential([
        tf.keras.layers.Conv2D(64,(3,3), activation = 'relu', input_shape = (28,28,1)),
        tf.keras.layers.MaxPooling2D(2,2),
        tf.keras.layers.Conv2D(64,(3,3), activation = 'relu'),
        tf.keras.layers.MaxPooling2D(2,2),
        tf.keras.layers.Flatten(),
        tf.keras.layers.Dense(128,activation = 'relu'),
        tf.keras.layers.Dense(10, activation = 'softmax')
])
model.compile(optimizer='adam', 
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])
model.fit(training_images, training_labels, epochs=5)
model.summary()
model.evaluate(test_images,test_labels)<jupyter_output>313/313 [==============================] - 1s 4ms/step - loss: 0.2693 - accuracy: 0.8998
{'fraction_non_alphanumeric': 0.19005524861878453, 'fraction_numerical': 0.05230202578268876, 'mean_word_length': 4.904347826086957, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '609340', 'license': 'Apache-2.0', 'n_tokens_mistral': 1041, 'n_tokens_neox': 942, 'n_words': 140, 'path': 'Day_1.ipynb', 'repo_name': 'madhavjk/DataScience-ML_and_DL', 'size': '2715'}