Welcome to the TensorFlow basics guide! This tutorial will help you get started with TensorFlow, a powerful open-source library for machine learning and deep learning. Let's dive in!

📚 Installation Guide

  1. Install TensorFlow
    Use pip to install TensorFlow:

    pip install tensorflow
    

    📌 Check our official documentation for more installation options

  2. Verify Installation
    Run a simple test in Python:

    import tensorflow as tf
    print(tf.__version__)
    

    ✅ If you see a version number, TensorFlow is successfully installed!

🧠 Core Concepts

  • Tensors
    Tensors are the fundamental data structures in TensorFlow. They can be thought of as multidimensional arrays.

    Tensor_Flow_Logo
  • Sessions
    Sessions are used to execute operations on tensors. In newer versions, eager execution is enabled by default.
    📌 Learn more about sessions and execution

  • Graphs
    TensorFlow uses computational graphs to represent operations. These graphs can be executed on CPUs or GPUs.

    Neural_Network_Structure

💻 Practical Example: MNIST Dataset

Let's build a simple neural network to classify digits from the MNIST dataset:

import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10)
])

model.compile(optimizer='adam',
              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
              metrics=['accuracy'])

model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test, verbose=2)

📌 Explore advanced TensorFlow techniques here

MNIST_Dataset

📖 Next Steps

Happy coding! 🚀