What does the function reduce mean do in tensorflow

This recipe explains what does the function reduce mean do in tensorflow

Recipe Objective

What does the function reduce_mean do?

This function will compute the mean of the elements across the dimensions of tensor. This is achived by using "math.mean" available in tensorflow, it will reduces the input_tensor along the dimensions of given in axis by computing mean of the elements across the dimensions in axis. The Rank of the tensor is reduced to 1 for each of the entries in the axis unless the "keepdims" is true. The reduced dimensions are retained with length 1 if the "keepdims" is true.

Hands-On Guide to the Art of Tuning Locality Sensitive Hashing in Python

Step 1 - Import library

import tensorflow as tf

Step 2 - Take Sample data

Sample_data = tf.constant([[2,3,4],[5,6,7]]) print("This is a Sample data:",Sample_data)

This is a Sample data: tf.Tensor(
[[2 3 4]
 [5 6 7]], shape=(2, 3), dtype=int32)

Step 3 - Print Results

reduced_mean = tf.math.reduce_mean(Sample_data) print("This is the result for reduce mean of Sample data:",reduced_mean)

This is the result for reduce mean of Sample data: tf.Tensor(4, shape=(), dtype=int32)

{"mode":"full","isActive":false}

What Users are saying..

profile image

Abhinav Agarwal

Graduate Student at Northwestern University
linkedin profile url

I come from Northwestern University, which is ranked 9th in the US. Although the high-quality academics at school taught me all the basics I needed, obtaining practical experience was a challenge.... Read More

Relevant Projects

OpenCV Project for Beginners to Learn Computer Vision Basics
In this OpenCV project, you will learn computer vision basics and the fundamentals of OpenCV library using Python.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

Detectron2 Object Detection and Segmentation Example Python
Object Detection using Detectron2 - Build a Dectectron2 model to detect the zones and inhibitions in antibiogram images.

Build Portfolio Optimization Machine Learning Models in R
Machine Learning Project for Financial Risk Modelling and Portfolio Optimization with R- Build a machine learning model in R to develop a strategy for building a portfolio for maximized returns.

Build a Text Classification Model with Attention Mechanism NLP
In this NLP Project, you will learn to build a multi class text classification model with attention mechanism.

Build a Similar Images Finder with Python, Keras, and Tensorflow
Build your own image similarity application using Python to search and find images of products that are similar to any given product. You will implement the K-Nearest Neighbor algorithm to find products with maximum similarity.

Deep Learning Project for Time Series Forecasting in Python
Deep Learning for Time Series Forecasting in Python -A Hands-On Approach to Build Deep Learning Models (MLP, CNN, LSTM, and a Hybrid Model CNN-LSTM) on Time Series Data.

Learn Object Tracking (SOT, MOT) using OpenCV and Python
Get Started with Object Tracking using OpenCV and Python - Learn to implement Multiple Instance Learning Tracker (MIL) algorithm, Generic Object Tracking Using Regression Networks Tracker (GOTURN) algorithm, Kernelized Correlation Filters Tracker (KCF) algorithm, Tracking, Learning, Detection Tracker (TLD) algorithm for single and multiple object tracking from various video clips.

Build a Logistic Regression Model in Python from Scratch
Regression project to implement logistic regression in python from scratch on streaming app data.