How to find sin cos and tan of a number using pytorch

This recipe helps you find sin cos and tan of a number using pytorch

Recipe Objective

How to find sin, cos and tan of a number using pytorch?

As the PyTorch is an open source library which is widely used for deep neural networks and natural language processing. The sin, cos, tan can be achieved in Pytorch bu using torch.sin, torch.cos, torch.tan in which the input will be a tensor which contains more than one elements, and according to element the output is computed.

Build Your First Text Classification Model using PyTorch

Step 1 - Import library

import torch

Step 2 - Take Sample tensor

Sample_torchtensor = torch.tensor([2.3, 4.5, 6.7, 8.9, 9.0, 0.2, -0.5, 6.7])

Step 3 - Print Results

print("This is SIN of Sample tensor", torch.sin(Sample_torchtensor), "\n")

print("This is COS of Sample tensor", torch.cos(Sample_torchtensor), "\n")

print("This is TAN of Sample tensor", torch.tan(Sample_torchtensor))

This is SIN of Sample tensor tensor([ 0.7457, -0.9775,  0.4048,  0.5010,  0.4121,  0.1987, -0.4794,  0.4048]) 

This is COS of Sample tensor tensor([-0.6663, -0.2108,  0.9144, -0.8654, -0.9111,  0.9801,  0.8776,  0.9144]) 

This is TAN of Sample tensor tensor([-1.1192,  4.6373,  0.4428, -0.5789, -0.4523,  0.2027, -0.5463,  0.4428])

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

What Users are saying..

profile image

Ray han

Tech Leader | Stanford / Yale University
linkedin profile url

I think that they are fantastic. I attended Yale and Stanford and have worked at Honeywell,Oracle, and Arthur Andersen(Accenture) in the US. I have taken Big Data and Hadoop,NoSQL, Spark, Hadoop... Read More

Relevant Projects

Predictive Analytics Project for Working Capital Optimization
In this Predictive Analytics Project, you will build a model to accurately forecast the timing of customer and supplier payments for optimizing working capital.

Multilabel Classification Project for Predicting Shipment Modes
Multilabel Classification Project to build a machine learning model that predicts the appropriate mode of transport for each shipment, using a transport dataset with 2000 unique products. The project explores and compares four different approaches to multilabel classification, including naive independent models, classifier chains, natively multilabel models, and multilabel to multiclass approaches.

Hands-On Approach to Causal Inference in Machine Learning
In this Machine Learning Project, you will learn to implement various causal inference techniques in Python to determine, how effective the sprinkler is in making the grass wet.

Build a Face Recognition System in Python using FaceNet
In this deep learning project, you will build your own face recognition system in Python using OpenCV and FaceNet by extracting features from an image of a person's face.

BigMart Sales Prediction ML Project in Python
The goal of the BigMart Sales Prediction ML project is to build and evaluate different predictive models and determine the sales of each product at a store.

Build a CNN Model with PyTorch for Image Classification
In this deep learning project, you will learn how to build an Image Classification Model using PyTorch CNN

OpenCV Project to Master Advanced Computer Vision Concepts
In this OpenCV project, you will learn to implement advanced computer vision concepts and algorithms in OpenCV library using Python.

Build Classification Algorithms for Digital Transformation[Banking]
Implement a machine learning approach using various classification techniques in Python to examine the digitalisation process of bank customers.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

AWS MLOps Project for Gaussian Process Time Series Modeling
MLOps Project to Build and Deploy a Gaussian Process Time Series Model in Python on AWS