Description: This notebook provides an introduction to TensorFlow and covers various concepts and operations.
Code Snippet:
Importing TensorFlow:
- Importing TensorFlow and checking the version.
Eager Execution:
- Checking if eager execution is enabled.
GPU Check:
- Checking if a GPU is available.
Constant and Variable Tensors:
- Creating constant and variable tensors using
tf.constant
andtf.Variable
.
Concatenation of Tensors:
- Concatenating tensors along rows and columns using
tf.concat
.
Zeros and Ones Tensors:
- Creating tensors filled with zeros and ones using
tf.zeros
andtf.ones
.
Tensor Transpose:
- Transposing a tensor using
tf.transpose
.
Type Conversion:
- Converting the tensor data type using
tf.cast
.
Multiplication and Matrix Multiplication:
- Performing element-wise multiplication and matrix multiplication using
tf.multiply
andtf.matmul
.
Determinant:
- Computing the determinant of a tensor using
tf.linalg.det
.
Identity:
- Creating an identity matrix using
tf.eye
.
Reshape:
- Reshaping a tensor using
tf.reshape
.
Keras:
- Importing the necessary modules from TensorFlow Keras.
Data Split:
- Splitting the CIFAR-10 dataset into training and testing sets using
cifar10.load_data()
.
Visualizing the Dataset:
- Visualizing a subset of images from the dataset using Matplotlib.
Text Vectorization:
- Performing text vectorization using
TextVectorization
layer from TensorFlow Keras.
Normalization:
- Normalizing the input data using the
Normalization
layer from TensorFlow Keras.
Description: This notebook demonstrates various data augmentation techniques using TensorFlow's ImageDataGenerator
and tf.image
functions to augment an image.
Code Snippet:
Importing Libraries and Uploading Image:
- Importing TensorFlow, Matplotlib, and the necessary modules from Keras and Google Colab.
- Uploading an image using
files.upload()
fromgoogle.colab
.
Preprocessing the Image:
- Resizing and rescaling the image using Resizing and Rescaling layers from
tf.keras.preprocessing.image
.
Image Augmentation Techniques:
- Randomly flipping the image horizontally and vertically using
RandomFlip
fromtf.keras.preprocessing.image
. - Randomly rotating the image by a specified angle using
RandomRotation
fromtf.keras.preprocessing.image
. - Applying a random invert function to invert the image based on a given probability.
- Flipping the image upside down using
flip_up_down
fromtf.image
. - Converting the image to grayscale using
rgb_to_grayscale
fromtf.image
. - Adjusting the saturation of the image using
adjust_saturation
fromtf.image
. - Adjusting the brightness of the image using
adjust_brightness
from `tf.image
`.
Using ImageDataGenerator
for Augmentation:
- Installing the necessary library
keras_preprocessing
. - Importing
ImageDataGenerator
fromkeras.preprocessing.image
. - Defining an instance of
ImageDataGenerator
with various augmentation settings. - Reshaping the image to match the expected input shape.
- Generating augmented images using
flow
fromdatagen
with a specified batch size. - Displaying the augmented images using Matplotlib.
Description: This notebook demonstrates logistic regression using TensorFlow for the Iris dataset.
Code Snippet:
Data loading and preprocessing:
- Loading the Iris dataset using
load_iris
fromsklearn.datasets
. - Splitting the dataset into input features
x
and target labelsy
. - Creating a DataFrame dataset to combine the features and labels.
Model building and training:
- Defining the model architecture using
tf.keras.layers.Dense
. - Compiling the model with an optimizer, loss function, and metrics.
- Fitting the model to the training data using
model.fit
.
Prediction:
- Making predictions on new data using the trained model.
Description: This notebook introduces the concept of perceptrons and demonstrates the use of single-layer perceptrons for the Iris dataset.
Code Snippet:
Perceptron Model:
- Loading the Iris dataset using
load_iris
fromsklearn.datasets
. - Splitting the dataset into input features
x
and target labelsy
. - Creating a Perceptron model using
sklearn.linear_model.Perceptron
. - Fitting the model to the training data using
model.fit
.
Multilayer Perceptron:
- Loading the MNIST dataset using
tf.keras.datasets.mnist.load_data
. - Preprocessing the data by normalizing and reshaping.
- Defining a multilayer perceptron model using
tf.keras.models.Sequential
andtf.keras.layers.Dense
. - Compiling and fitting the model to the training data.
- Evaluating the model on the test data.
Description: This notebook showcases the use of Convolutional Neural Networks (CNNs) for the MNIST handwritten digit classification task.
Code Snippet:
Data Preprocessing:
- Loading the MNIST dataset using
keras.datasets.mnist.load_data
. - Reshaping and normalizing the data.
Model Architecture:
- Building a CNN model using
keras.layers.Convolution2D
,keras.layers.MaxPooling2D
, andkeras.layers.Dense
. - Compiling the model with appropriate loss and optimizer.
Training and Evaluation:
- Fitting the model to the training data using
model.fit
. - Predicting on new images and displaying the results.