Trending December 2023 # How To Use The Driving Focus On Iphone : A Complete Guide # Suggested January 2024 # Top 19 Popular

You are reading the article How To Use The Driving Focus On Iphone : A Complete Guide updated in December 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 How To Use The Driving Focus On Iphone : A Complete Guide

When it comes to driving, there’s one thing you should never do: “check your phone,” and you should surely do is use Driving Focus on your iPhone.

Most people drive because they enjoy the freedom of cruising down the road while listening to music or talking on their cell phones. However, many forget that these activities can be quite risky. We’ve all experienced a time when the phone starts ringing while driving.

A simple solution to manage the situation is iPhone’s Driving Focus mode. But do you know how to use it? I’ll show you how to set it up and how exactly it works.

What is Driving Focus mode on your iPhone?

Earlier dubbed as Do Not Disturb While Driving, it is now incorporated in Focus mode with iOS 15. It helps you to concentrate on the road and reduces clutter while driving. It temporarily limits calls, texts, and other notifications.

A “Motor Car” icon appears on your iPhone after you turn on the Driving Focus mode. The icon’s appearance indicates that your device will now support features such as auto-reply and read replies with Siri.

How to set up Driving Focus mode

Setting up the Driving Focus was a bit complex on iOS 15. To fix it, Apple has smoothened it and made it fairly simple on iOS 16. We’ll see how to set up the Driving Focus mode in both versions.

In iOS 16

Select who can or can’t call you: Tap the People tab; you’ll have two options to choose from:

Customize your Lock Screen: iOS 16 brings automation and customizations to the Lock Screen. Thanks to it, you can link your Focus mode profiles with a lockscreen to reduce driving distractions.

In iOS 15

Note: If you’ve tried setting up Driving Focus before, simply go to Settings → Focus and select Driving to start customizing it.

Turn on or off Driving Focus mode 

To enable/disable the Driving Focus mode in iOS 16 or iOS 15.

Alternatively, you can also:

In iOS 16 – On the Lock Screen, long-press the screen → swipe left or right to choose the look screen for which you’ve linked the Focus status.

In iOS 15 – On the Lock Screen, long-press the Motor car icon (or Driving text) → tap Driving mode to turn it off.

Sometimes, you may get an alert when trying to unlock your screen. Choose, I’m not driving to disable Driving Focus.

Automate replies while driving

You can even set a custom message to inform people that you’re driving or will call later, etc. Notably, you can select a certain person or group that this message goes to. To set an automated message:

Notably, the selected contacts can also notify you if there’s something essential that needs to be delivered by sending “Urgent” as a supplement message.

Automate the Driving Focus mode

You can turn on Driving Focus mode on its own if the iPhone is connected to the car’s Bluetooth or CarPlay and the car is in motion (or you’re moving fast). To enable the automation:

Share Focus Status

You can let others know you’re driving by sharing a Focus status. This will let others know that you have your notifications silenced. Apple has tweaked the setting with iOS 16 as the Focus status now gets a separate section.

In iOS 15: Go to Settings → Focus → Driving → Focus Status → Toggle on Share Focus Status.

And that’s how it’s done!

Read more:

Author Profile


Tech Junkie and Computer Science Undergrad, who loves experimenting things and everything Apple.

You're reading How To Use The Driving Focus On Iphone : A Complete Guide

How To Use Google Tasks: The Complete Guide

Whether it’s taking out the garbage or picking up your suit from the dry cleaners, there are always things you need to get done. You may already have a to-do app installed to stay on top of things, but you can bet that Google would like you to try their Task appg.

If you like apps that keep things simple, then you just might like the Google Tasks app. At least you have the assurance that the app is from a company whose other services you’re probably already using.

What Google Tasks Has to Offer (Android)

Besides offering a very essential feature for a to-do app, Google Tasks also makes the app easy to use. Tap on the “Add a new task” button and add what you need to do. To add details to your new task, tap on the “+” sign.

If you select the uneven lines, you can add details to your new task, and by tapping on the Calendar icon, you can also add a date. So far, there are no options to add an image or a specific time to your task.

You can also change your list’s name if you’re not happy with the name. Tap on the three vertical dots at the bottom-right, and there you can either change the name or delete altogether. At the top you can also change the order you see your tasks. For example, you can either sort them by date, or you can order them in the way you created them.

There’s also the possibility of adding sub-tasks to your already-created tasks.  If you’ve already created your task, just tap on it, and the “Add subtasks” option should be the last one.

Tap on the dropdown menu to the side of the name of the task, and you can move your task to another list. When you’ve completed a task, tap on the empty circle to the side of the task, and it will be placed in the completed tasks list. To edit your task, just tap on the pencil icon.

Drag and Drop Your Tasks

Placing your tasks in a different order is also possible. Long-press on the task you want to move and drop it in the order you want. You can even make a particular task stand out from the rest by placing the task slightly to the right  of where you drop it.

Having a task placed slightly to the right from the rest is something that can’t be done on the desktop version.

Google Tasks on Your Desktop

Once you have the new design, you’ll see a couple of icons right below your profile picture. One of those icons will be Tasks, and it will have a blue circle with a while pencil in the middle.

This last option does not appear on Tasks for Android. Instead, it offers an option to delete all completed tasks.

How to Add an Email to Google Tasks List

If there’s an email you’ve been meaning to answer but just keep forgetting, add it to your task list. Just find the email and drag it to your already-open task list.


Fabio Buckell

Just a simple guy that can’t enough of Technology in general and is always surrounded by at least one Android and iOS device. I’m a Pizza addict as well.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

How To Use The Focus Sessions Widget On Windows 11

How to use the Focus Sessions widget on Windows 11 Microsoft just released the 23481 Build to Windows Insiders.




The Focus Sessions widget will be available in the coming months.

You can easily keep track of your work with it.

It being a widget means you’ll no longer forget about it.

Good news for Windows 11 users this week: it seems that you can use the Focus Sessions widget on the operating system sooner than expected.

Microsoft released Windows 11 Insider Preview Build 23481 to the Dev Channel and you can download the ISO file as well if you find it more convenient this way.

The release brings some important improvements to Windows Ink, which is a very useful tool for organizations. But among the new features, the Focus Sessions widget steals the show.

The Focus Session feature is already on Windows 11, but not as a widget, though. You can find it in the taskbar, below your calendar, and it’s very useful for when you have to focus at work. However, you can easily forget about it, because it’s simply not in your glance.

Here’s how you can use the Focus Sessions widget on Windows 11

Because it’s not in your glance, you can easily forget about using the Focus Sessions option, however, Microsoft is putting it in a widget, so that way, you can use it when you check for the weather. Or when you’re using the other widgets.

The new Focus Sessions Widget will be part of the Clock app update, and currently, it’s available in Microsoft Store in Windows Insiders in the Canary and Dev Channels.

As you can see, accessing it will be very easy.

Expert tip:

Here’s the complete list:

Changes and Improvements [Taskbar & System Tray]

Never combined mode, which enables you to see each window of your applications on the taskbar individually, and which began rolling out with Build 23466, is now available to all Windows Insiders in the Dev Channel.

Taskbar in never combined mode.

Starting with his build, Chat is now Microsoft Teams – Free. Microsoft Teams – Free is pinned by default to the taskbar and can be unpinned like other apps on the taskbar. Stay tuned for more enhancements as we continue to enhance Microsoft Teams – Free with more features and improvements.

[File Explorer]

The ability to tear out and merge tabs in File Explorer, which began rolling out with Build 23471, is now available to all Windows Insiders in the Dev Channel.

[Voice access]

The new text authoring experiences in voice access that began rolling out with Build 23466 is now available to all Windows Insiders in the Dev Channel.

Fixes [Dev Drive]

Fixed an issue where filters beyond AV might be attached to your Dev Drive on reboot.

Fixed an issue which could cause a bugcheck when using Dev Drive.

[File Explorer]

We fixed the following issues for Insiders with the modernized address bar in File Explorer:

We fixed the following issues for Insiders who have the modernized File Explorer Home:

Fixed an issue where hovering over folders in the Quick Access section of Home was causing the name to disappear and the icon to slide to the side if you had checkboxes enabled.

Dragging and dropping into the Favorites or Quick Access sections should work again now.

[Search on the Taskbar]

Fixed an issue where navigating the search flyout on the taskbar with the keyboard arrow keys did not work as expected.

NOTE: Some fixes noted here in Insider Preview builds from the Dev Channel may make their way into the servicing updates for the released version of Windows 11.

Known issues [Dev Drive]

There might be variable performance on different hardware. If you notice slower performance on your machine, please file feedback!

[Search on the Taskbar]

Text scaling may not work in the search flyout.

[File Explorer]

Insiders may experience a File Explorer crash when dragging the scroll bar or attempting to close the window during an extended file-loading process.

Thumbnail loading performance in Gallery for dehydrated cloud files and memory usage in large collections are known issues we are focused on improving. Please capture Performance traces in Feedback Hub for any performance-related issues. Rebuilding your Indexer can help if thumbnails are missing for cloud files; Search for “Indexing Options” and look in Advanced settings to find the rebuild tool.

[NEW] The count shown for selected files in the details pane may be extremely large.

Insiders who have the modernized File Explorer Home that began rolling out with Build 23475:

File Type icons are displayed in place of file thumbnails for ‘Recommended’ section (applicable to Enterprise users).

Insiders signed in with an AAD account and try to navigate the Recommended section on File Explorer Home with the tab key on the keyboard may experience an chúng tôi crash.

When navigating from another group to the Recommended section using a keyboard, focus does not appear on the group header or files appropriately.

Files display file extensions with the Show file extensions setting disabled.

Insiders who have the modernized File Explorer address bar that began rolling out with Build 23475:

Windows Insiders may notice missing craftmanship polish with the modernized address bar and search box. The team greatly appreciates the use of Feedback Hub to help call out important details to address.

Users might experience lost keyboard focus and missing keyboard shortcuts. The team implemented improved tabbing with keyboard shortcuts that will be available soon.

[NEW] If “…” shows in the address bar path, selecting it will crash explorer.exe.

Insiders will have issues with the following commands on recommended files in File Explorer that began rolling out with Build 23403:


The copy button for quickly copying two-factor authentication (2FA) codes in notification toasts (first introduced in Build 23403) is currently not working in this build. A fix is coming in a future flight.

[Dynamic Lighting]

On first boot after installing this build and connecting a device, the “Use Dynamic Lighting on my devices” toggle is off in Settings. Device LEDs may not turn on automatically. Turning this toggle on in the all-device Settings page and in the per-device page(s) should turn on your device’s LEDs. If this doesn’t work, try restarting your Windows PC again.

All-device settings changes are not propagating to per-device Settings.

Device icons are missing from the device cards in Settings.

Switching user accounts can turn off device LEDs.

[Windows Ink]

Was this page helpful?


Start a conversation

A Complete Guide To K


In the four years of my data science career, I have built more than 80% of classification models and just 15-20% of regression models. These ratios can be more or less generalized throughout the industry. The reason behind this bias towards classification models is that most analytical problems involve making decisions. In this article, we will talk about one such widely used machine learning classification technique called k nearest neighbor (KNN) algorithm. Our focus will primarily be on how the algorithm works on new data and how the input parameter affects the output/prediction.

Note: People who prefer to learn through videos can learn the same through our free course – K-Nearest Neighbors (KNN) Algorithm in Python and R. And if you are a complete beginner to Data Science and Machine Learning, check out our Certified BlackBelt program –

Learning Objectives

Understand the working of KNN and how it operates in python and R.

Get to know how to choose the right value of k for KNN

Understand the difference between training error rate and validation error rate

What is KNN (K-Nearest Neighbor) Algorithm?

The K-Nearest Neighbor (KNN) algorithm is a popular machine learning technique used for classification and regression tasks. It relies on the idea that similar data points tend to have similar labels or values.

During the training phase, the KNN algorithm stores the entire training dataset as a reference. When making predictions, it calculates the distance between the input data point and all the training examples, using a chosen distance metric such as Euclidean distance.

Next, the algorithm identifies the K nearest neighbors to the input data point based on their distances. In the case of classification, the algorithm assigns the most common class label among the K neighbors as the predicted label for the input data point. For regression, it calculates the average or weighted average of the target values of the K neighbors to predict the value for the input data point.

The KNN algorithm is straightforward and easy to understand, making it a popular choice in various domains. However, its performance can be affected by the choice of K and the distance metric, so careful parameter tuning is necessary for optimal results.

When Do We Use the KNN Algorithm?

KNN can be used for both classification and regression predictive problems. However, it is more widely used in classification problems in the industry. To evaluate any technique, we generally look at 3 important aspects:

1. Ease of interpreting output

2. Calculation time

3. Predictive Power

Let us take a few examples to  place KNN in the scale :

KNN classifier fairs across all parameters of consideration. It is commonly used for its ease of interpretation and low calculation time.

How Does the KNN Algorithm Work?

Let’s take a simple case to understand this algorithm. Following is a spread of red circles (RC) and green squares (GS):

You intend to find out the class of the blue star (BS). BS can either be RC or GS and nothing else. The “K” in KNN algorithm is the nearest neighbor we wish to take the vote from. Let’s say K = 3. Hence, we will now make a circle with BS as the center just as big as to enclose only three data points on the plane. Refer to the following diagram for more details:

The three closest points to BS are all RC. Hence, with a good confidence level, we can say that the BS should belong to the class RC. Here, the choice became obvious as all three votes from the closest neighbor went to RC. The choice of the parameter K is very crucial in this algorithm. Next, we will understand the factors to be considered to conclude the best K.

How Do We Choose the Factor K?

First, let us try to understand exactly the K influence in the algorithm. If we see the last example, given that all the 6 training observation remain constant, with a given K value we can make boundaries of each class. These decision boundaries will segregate RC from GS. In the same way, let’s try to see the effect of value “K” on the class boundaries. The following are the different boundaries separating the two classes with different values of K.

If you watch carefully, you can see that the boundary becomes smoother with increasing value of K. With K increasing to infinity it finally becomes all blue or all red depending on the total majority.  The training error rate and the validation error rate are two parameters we need to access different K-value. Following is the curve for the training error rate with a varying value of K :

As you can see, the error rate at K=1 is always zero for the training sample. This is because the closest point to any training data point is itself.Hence the prediction is always accurate with K=1. If validation error curve would have been similar, our choice of K would have been 1. Following is the validation error curve with varying value of K:

This makes the story more clear. At K=1, we were overfitting the boundaries. Hence, error rate initially decreases and reaches a minima. After the minima point, it then increase with increasing K. To get the optimal value of K, you can segregate the training and validation from the initial dataset. Now plot the validation error curve to get the optimal value of K. This value of K should be used for all predictions.

The above content can be understood more intuitively using our free course – K-Nearest Neighbors (KNN) Algorithm in Python and R

Breaking It Down – Pseudo Code of KNN

We can implement a KNN model by following the below steps:

Load the data

Initialise the value of k

For getting the predicted class, iterate from 1 to total number of training data points

Calculate the distance between test data and each row of training dataset. Here we will use Euclidean distance as our distance metric since it’s the most popular method. The other distance function or metrics that can be used are Manhattan distance, Minkowski distance, Chebyshev, cosine, etc. If there are categorical variables, hamming distance can be used.

Sort the calculated distances in ascending order based on distance values

Get top k rows from the sorted array

Get the most frequent class of these rows

Return the predicted class

Implementation in Python From Scratch

We will be using the popular Iris dataset for building our KNN model. You can download it from here.

Comparing Our Model With Scikit-learn from sklearn.neighbors import KNeighborsClassifier neigh = KNeighborsClassifier(n_neighbors=3)[:,0:4], data['Name']) # Predicted class print(neigh.predict(test)) # 3 nearest neighbors print(neigh.kneighbors(test)[1])

We can see that both the models predicted the same class (‘Iris-virginica’) and the same nearest neighbors ( [141 139 120] ). Hence we can conclude that our model runs as expected.

Implementation of KNN in R

View the code on Gist.


#Top observations present in the data SepalLength SepalWidth PetalLength PetalWidth Name 1 5.1 3.5 1.4 0.2 Iris-setosa 2 4.9 3.0 1.4 0.2 Iris-setosa 3 4.7 3.2 1.3 0.2 Iris-setosa 4 4.6 3.1 1.5 0.2 Iris-setosa 5 5.0 3.6 1.4 0.2 Iris-setosa 6 5.4 3.9 1.7 0.4 Iris-setosa #Check the dimensions of the data [1] 150 5 #Summarise the data SepalLength SepalWidth PetalLength PetalWidth Name Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100 Iris-setosa :50 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300 Iris-versicolor:50 Median :5.800 Median :3.000 Median :4.350 Median :1.300 Iris-virginica :50 Mean :5.843 Mean :3.054 Mean :3.759 Mean :1.199 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800 Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500

Step 3: Splitting the Data

View the code on Gist.

Step 4: Calculating the Euclidean Distance

View the code on Gist. View the code on Gist.


For K=1 [1] "Iris-virginica"

In the same way, you can compute for other values of K.

Comparing Our KNN Predictor Function With “Class” Library

View the code on Gist.


For K=1 [1] "Iris-virginica"

We can see that both models predicted the same class (‘Iris-virginica’).


The KNN algorithm is one of the simplest classification algorithms. Even with such simplicity, it can give highly competitive results. KNN algorithm can also be used for regression problems. The only difference from the discussed methodology will be using averages of nearest neighbors rather than voting from nearest neighbors. KNN can be coded in a single line on R. I am yet to explore how we can use the KNN algorithm on SAS.

Key Takeaways

KNN classifier operates by finding the k nearest neighbors to a given data point, and it takes the majority vote to classify the data point.

The value of k is crucial, and one needs to choose it wisely to prevent overfitting or underfitting the model.

One can use cross-validation to select the optimal value of k for the k-NN algorithm, which helps improve its performance and prevent overfitting or underfitting. Cross-validation is also used to identify the outliers before applying the KNN algorithm.

The above article provides implementations of KNN in Python and R, and it compares the result with scikit-learn and the “Class” library in R.

Frequently Asked Questions Related

A Complete Guide To The Google Fred Algorithm

March 8, 2023, was a day that started out like any other…

You were sat at your desk, casually sipping your first cup of coffee and catching up with the search news here on Search Engine Journal, or perhaps scrolling through your Facebook feed, when it hit you…

You headed over to your favorite rank-checking tool.

“Please God, just let my site/clients be OK,” you quietly prayed.

Depending on your strategies and sites, the impact was almost certainly significant. Losers lost big, and the winners took their place.

Fred was here.

Why Name the Algorithm Fred?

According to Google’s very sarcastic Gary Illyes, ‘Fred’ is the name of every update Google doesn’t give us a name for.

sure! From now on every update, unless otherwise stated, shall be called Fred

— Gary 鯨理/경리 Illyes (@methode) March 9, 2023

With that said, when we refer to the “Fred Update,” we are typically referring to the update that rolled out on March 7, 2023.

Unless otherwise noted, any reference to Fred below will be in this context and not a compilation of all the “unnamed” updates since then.

Fred’s Timing

Fred has interesting timing.

Fred was preceded a month earlier by a major Google Core Update, which was said to focus on E-A-T.

A week after Fred, Google announced Project Owl, which was designed to clear away misleading and offensive information based on feedback from their quality raters.

Now, let’s be clear: The raters were training the system to recognize inaccurate or offensive information, not making the decision as to what sites should be purged from the results.

Clearly, Google was highly focused on quality and using data from their quality raters.

Fred was no exception.

What Was Google’s Fred Algorithm?

Google’s Fred algorithm update rolled out in an attempt to remove what Google perceived as low-quality results — sites that relied on thin content and aggressive ad placement.

Many were affiliate sites, though not all.

The majority used content as their primary traffic driver. Ordinarily, we hear Google telling folks to do just that.

While Gary gave us a name for the update, he didn’t give us a list of the areas they were addressing aside from the statement:

Fred is closely related to quality section of rater guidelines. @methode #smx

— Jennifer Slegg (@jenstar) June 13, 2023

That tells us that it did have to do with E-A-T, and the impacted sites imply that the areas it targeted were some or all of:

Thin content.

Poor link quality.

Poor content quality.

Aggressive affiliate linking.

Overwhelming interstitials.

Disproportionate Main Content/Supplemental Content ratio.

If you want a refresher on E-A-T and the Quality Raters’ Guidelines, you’ll find one here.

From the Horse’s Mouth

Jenn Slegg interviewed Gary Illyes on the topic at Brighton SEO in 2023.

Here’s a transcript of their discussion.

When it came to Fred, it all came basically down to the following:

Freds, Not Fred

Gary reinforced in the interview that Fred is the name of every unnamed update. As noted above, that’s all well and good for him to state but is a bit useless for SEO pros.

This is why we are typically referring to the single update.

Google Doesn’t Like That We Care About Updates

Gary goes on to note,

“I don’t like that people are focusing on [updates]. Every single update that we make is around quality of the site or general quality, perceived quality of the site, content, and the links or whatever.”

They would rather we just focused our time and attention on meeting the user’s needs than analyzing updates and chasing the metrics they imply.

Most Updates are Unactionable

With two to three updates per day, Gary rightfully points out that most are addressing unactionable areas like how words are structured on a page in a specific language.

I just want to stress the use of the word “most.”

Links Matter

Gary says,

“Basically, if you publish high quality content that is highly cited on the internet …”

He goes on to be a bit tongue-in-cheek, but it’s clear that a goal should be building quality content that attracts links.

It’s not news or Fred-specific, but worth noting.

Q&A with Gary Illyes

You can watch a full video of the interview below. The portion on Fred begins at 4:30.

Dave’s Take

I’m not a huge fan of how Gary sort of sidesteps what Fred is by discussing it in the plural. He knows the question is about the March 7 update and not all of the Freds.

And the likelihood that they updated all the algorithms at once is… well, I suppose I can’t say 0%, but it’s as close to that as possible.

Other than that, his answers were predictable but revealing:

Most updates aren’t actionable (in that there’s literally nothing that can be done – not that there are only things Google tells you they don’t want you to do like link building).

All sites fluctuate.

When in doubt, read the Webmaster Guidelines (and I would add the Quality Raters Guidelines).

Gary is sarcastic and pretty funny.

Recovering From the Fred Update

Thankfully, if you’re ranking now, you’ve probably been doing the things that will keep you from getting hit by similar updates.

Those who wanted to recover from this update had a big, big task ahead of them. Typically, they needed to revisit their site structure to reduce the ad layout and on top of that, revisit their content page-by-page to ensure it actually deserved a spot in the top 10.

Some did. But many didn’t.

Some tried to shortcut it.

Barry Schwartz compiled a list of sites he knew to have been hit.

Here’s how some did:

Seems they tried to trick their way back in.

Looks familiar, but the second drop took a bit longer. The follow-up hit would be one of three updates.

A flurry of manual actions were sent out around this time. This is the least likely.

Quality updates that occurred around this time.

And Marie Haynes reported seeing a number of sites impacted around June 17th and 18th that had previous link-related issues.

I suspect the third is the most likely.

Again, we see some recovery, and then subsequent hits in additional quality updates.

Google will get their way eventually.


Those who’ve been doing SEO recently will be used to updates like Fred, but in 2023 it was different than updates before it.

Stronger. More targeted. More effective. More devastating… or rewarding.

I remember when Fred rolled out. While my own clients weren’t impacted significantly one way or the other, it put a stamp on what was to come.

We’d seen quality updates and spam cleansers before, but this one somehow felt different. And it was.

After Fred, the updates around quality came more frequently and more varied. I credit that with the rise of machine learning but whatever the reason, as a searcher and someone who likes informative content, I appreciate it.

And hopefully, you feel you’ve found it here as well.

More Resources:

Image Credits

All screenshots taken by author, August of 2023

A Complete Guide To Pytorch Tensors

Introduction to PyTorch Tensors

The following article provides an outline for PyTorch Tensors. PyTorch was released as an open-source framework in 2023 by Facebook, and it has been very popular among developers and the research community. PyTorch has made building deep neural network models by providing easy programming and faster computation. However, PyTorch’s strong feature is providing Tensors. Tensors are defined as single dimensions or a matrix of a multi-dimensional array containing an element of single data types.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Tensors are also used in the Tensorflow framework, which Google released. NumPy Arrays in Python are basically just tensors processed by using GPUs or TPUs for training neural network models. PyTorch has libraries included in it for calculating gradient descent for feed-forward networks as well as back-propagation. PyTorch has more support to the Python libraries like NumPy and Scipy compared to other frameworks like Tensorflow.

PyTorch Tensors Dimensions

In any linear algebraic operations, the user may have data in vector, matrix or N-dimensional form. Vector is basically a single-dimensional tensor, Matrix is two-dimensional tensors, and an Image is a 3-dimensional tensor with RGB as a dimension. PyTorch tensor is a multi-dimensional array, same as NumPy and also it acts as a container or storage for the number. To create any neural network for a deep learning model, all linear algebraic operations are performed on Tensors to transform one tensor to new tensors.


import torch tensor_1 = torch.rand(3,3)

Here random tensor of size 3*3 is created.

How to Create PyTorch Tensors Using Various Methods

Let’s create a different PyTorch tensor before creating any tensor import torch class using the below command:


import torch

1. Create tensor from pre-existing data in list or sequence form using torch class.

It is a 2*3 matrix with values as 0 and 1.


torch.tensor(data, dtype=None, device=None, requires_grad=False, pin_memory=False)


import torch tensor_b = torch.Tensor([[0,0,0], [1,1,1]]) tensor_b


2. Create n*m tensor from random function in the torch.


torch.randn(data_size, dtype=input.dtype, layout=input.layout, device=input.device)


import torch tensor_a = torch.rand((3, 3)) tensor_a


3. Creating a tensor from numerical types using functions such as ones and zeros.

torch.zeros(data_size, dtype=input.dtype, layout=input.layout, device=input.device)


tensor_d = torch.zeros(3, 3) tensor_d


In the above, tensor .zeros() is used to create a 3*3 matrix with all the values as ‘0’ (zero).

4. Creating a PyTorch tensor from the numpy tensor.

To create a tensor from numpy, create an array using numpy and then convert it to tensor using the .as_tensor keyword.


torch.as_tensor(data, dtype=None, device=None)


import numpy arr = numpy.array([0, 1, 2, 4]) tensor_e = torch.as_tensor(arr) tensor_e


Here is the basic tensor operation to perform the matrix product and get a new tensor.


tensor_e = torch.Tensor([[1, 2], [7, 8]]) tensor_f = torch.Tensor([[10], [20]]) tensor_mat = tensor_mat



Here is the list and information on parameters used in syntax:

data: Data for tensors.

dtype: Datatype of the returned tensor.

device: Device used is CPU or CUDA device with returned tensor.

requires_grad: It is a boolean data type with values as True or False to record automatic gradient on returned tensor.

data_size: Data shape of the input tensor.

pin_memory: If the pin_memory is set to Truly returned tensor will have pinned memory.

See below jupyter notebook for the above operation to create tensors.

Importance of Tensors in PyTorch

Tensor is the building block of the PyTorch libraries with a matrix-like structure. Tensors are important in PyTorch framework as it supports to perform a mathematical operation on the data.

Following are some of the key important points of tensors in PyTorch:

Tensors are important in the PyTorch as it is a fundamental data structure and all the neural network models are built using tensors as it has the ability to perform linear algebra operations

Tensors are similar to numpy arrays, but they are way more powerful than the numpy array as They perform their computation GPU or CPU. Hence, It is way more faster than the numpy library of python.

It offers seamless interoperability with Python libraries so that the programmer can easily use Sci-kit, SciPy libraries with tensors. Also, using functions like as_tensors or from_numpy programmer can easily convert the numpy array to PyTorch tensors.

One of the important features offered by tensor is it can store track of all the operations performed on them, which helps to compute the gradient descent of output; this can be done using Autograd functionality of tensors.

It is a multi-dimensional array which holds data for Images that can be converted into a 3-dimensional array based on its color like RGB (Red, Green and Blue); also, it holds Audio data or Time series data; any unstructured data can be addressed using tensors.


To learn PyTorch framework for building deep learning models for computer vision, Natural language processing or reinforcement learning. In the above tutorial, a programmer can get an idea of how useful and simple it is to learn and implement tensors in PyTorch. Of course, tensors can be used in PyTorch as well as Tensorflow. Still, the basic idea behind using tensors stays the same: using GPU or CPU with Cuda cores to process data faster which one framework to use for building models is developers decisions. Still, the above articles give a clear idea about tensor in the PyTorch.

Recommended Articles

We hope that this EDUCBA information on “PyTorch Tensors” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

Update the detailed information about How To Use The Driving Focus On Iphone : A Complete Guide on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!