0% found this document useful (0 votes)
14 views3 pages

Tensor Flow Detailed Notes

TensorFlow is an open-source library developed by Google for machine learning and deep learning, supporting various computational units like CPU, GPU, and TPU. It utilizes tensors as the basic data unit, allows for variable updates during training, and provides various operations for arithmetic, matrix manipulation, and neural network construction. Key features include easy deployment, integration with Keras, and support for large-scale computations.

Uploaded by

rasheedfahad340
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Tensor Flow Detailed Notes

TensorFlow is an open-source library developed by Google for machine learning and deep learning, supporting various computational units like CPU, GPU, and TPU. It utilizes tensors as the basic data unit, allows for variable updates during training, and provides various operations for arithmetic, matrix manipulation, and neural network construction. Key features include easy deployment, integration with Keras, and support for large-scale computations.

Uploaded by

rasheedfahad340
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

TensorFlow – Detailed Notes

1. Introduction to TensorFlow
TensorFlow is an open-source Python library for machine learning and deep learning developed by
Google. - Used for building neural networks - Handles large-scale numerical computations - Supports
CPU, GPU, and TPU for computation

import tensorflow as tf

2. Core Concepts

2.1 Tensors

• Multi-dimensional arrays (like NumPy arrays)


• Basic unit of data in TensorFlow

a = [Link]([[1, 2], [3, 4]])


print(a)

- [Link]() → Creates a constant tensor - Tensors have shape and dtype

Attributes: - [Link] → Shape of the tensor - [Link] → Data type of tensor elements - [Link]
→ Number of dimensions

2.2 Variables

• TensorFlow variables can be updated during training

v = [Link]([1, 2, 3], dtype=tf.float32)


[Link]([4,5,6])

3. Tensor Operations

Arithmetic Operations

a = [Link]([1, 2, 3])
b = [Link]([4, 5, 6])

print([Link](a,b)) # Addition
print([Link](b,a)) # Subtraction

1
print([Link](a,b)) # Element-wise multiplication
print([Link](b,a)) # Element-wise division

Matrix Operations

A = [Link]([[1,2],[3,4]])
B = [Link]([[5,6],[7,8]])
[Link](A,B) # Matrix multiplication

Reduction Operations

tf.reduce_sum(a)
tf.reduce_mean(a)
tf.reduce_max(a)
tf.reduce_min(a)

4. Neural Network Basics

4.1 Layers

• [Link] → Fully connected layer

from [Link] import layers


layer = [Link](units=10, activation='relu')

4.2 Models

• Sequential model → Layers stacked sequentially

from [Link] import Sequential


model = Sequential([
[Link](10, activation='relu', input_shape=(5,)),
[Link](1)
])

4.3 Compile Model

[Link](optimizer='adam', loss='mse', metrics=['mae'])

- optimizer → Method to update weights - loss → Loss function - metrics → Performance


evaluation

4.4 Train Model

2
[Link](X_train, y_train, epochs=10, batch_size=32)

- epochs → Number of times entire dataset is passed - batch_size → Number of samples per
gradient update

5. Evaluation and Prediction

[Link](X_test, y_test)
[Link](X_new)

6. Advantages of TensorFlow
• Handles large-scale computations
• Supports distributed computing
• Easy deployment to cloud or mobile
• Integration with Keras for simplified API
• Supports both CPU and GPU

7. Simple Example Program

import tensorflow as tf

# Create tensors
a = [Link]([1,2,3])
b = [Link]([4,5,6])

# Operations
c = [Link](a,b)
d = [Link](a,b)
print(c)
print(d)

# Build a simple neural network


from [Link] import Sequential, layers
model = Sequential([
[Link](10, activation='relu', input_shape=(3,)),
[Link](1)
])
[Link](optimizer='adam', loss='mse')
print([Link]())

You might also like