From 2604ecd61a9911d1d73e764046ee09c78ab5fb05 Mon Sep 17 00:00:00 2001 From: rohit Date: Sat, 18 May 2024 21:51:53 +0530 Subject: [PATCH] Added TensorFlow,md File --- contrib/machine-learning/index.md | 2 +- contrib/machine-learning/tensorFlow.md | 64 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 contrib/machine-learning/tensorFlow.md diff --git a/contrib/machine-learning/index.md b/contrib/machine-learning/index.md index 82596a2..1abe707 100644 --- a/contrib/machine-learning/index.md +++ b/contrib/machine-learning/index.md @@ -1,3 +1,3 @@ # List of sections -- [Section title](filename.md) +- [TensorFlow.md](learn-python\contrib\machine-learning\tensorFlow.md) diff --git a/contrib/machine-learning/tensorFlow.md b/contrib/machine-learning/tensorFlow.md new file mode 100644 index 0000000..1d9357d --- /dev/null +++ b/contrib/machine-learning/tensorFlow.md @@ -0,0 +1,64 @@ +# TensorFlow + +Developed by the Google Brain team, TensorFlow is an open-source library that provides a comprehensive ecosystem for building and deploying machine learning models. It supports deep learning and neural networks and offers tools for both beginners and experts. + +## Key Features + +- **Flexible and comprehensive ecosystem** +- **Scalable for both production and research** +- **Supports CPUs, GPUs, and TPUs** + +## Basic Example: Linear Regression + +Let's start with a simple linear regression example in TensorFlow. + +```python +import tensorflow as tf +import numpy as np +import matplotlib.pyplot as plt + +# Generate synthetic data +X = np.array([1, 2, 3, 4, 5], dtype=np.float32) +Y = np.array([2, 4, 6, 8, 10], dtype=np.float32) + +# Define the model +model = tf.keras.Sequential([ + tf.keras.layers.Dense(units=1, input_shape=[1]) +]) + +# Compile the model +model.compile(optimizer='sgd', loss='mean_squared_error') + +# Train the model +history = model.fit(X, Y, epochs=500) + +# Predict +predictions = model.predict(X) + +# Plot the results +plt.plot(X, Y, 'ro', label='Original data') +plt.plot(X, predictions, 'b-', label='Fitted line') +plt.legend() +plt.show() +``` + +In this example: + +1. We define a simple dataset with a linear relationship. +2. We build a sequential model with one dense layer (linear regression). +3. We compile the model with stochastic gradient descent (SGD) optimizer and mean squared error loss. +4. We train the model for 500 epochs and then plot the original data and the fitted line. + +## When to Use TensorFlow + +TensorFlow is a great choice if you: + +- **Need to deploy machine learning models in production:** TensorFlow’s robust deployment options, including TensorFlow Serving, TensorFlow Lite, and TensorFlow.js, make it ideal for production environments. +- **Work on large-scale deep learning projects:** TensorFlow’s comprehensive ecosystem supports distributed training and has tools like TensorBoard for visualization. +- **Require high performance and scalability:** TensorFlow is optimized for performance and can leverage GPUs and TPUs for accelerated computing. +- **Want extensive support and documentation:** TensorFlow has a large community and extensive documentation, which can be very helpful for both beginners and advanced users. + +## Example Use Cases + +- Building and deploying complex neural networks for image recognition, natural language processing, or recommendation systems. +- Developing models that need to be run on mobile or embedded devices. \ No newline at end of file