# Python | PyTorch atan() method

• Last Updated : 06 Jan, 2022

PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes.

The function `torch.atan()` provides support for the inverse tangent function in PyTorch. It gives the output in radian form. The input type is tensor and if the input contains more than one element, element-wise inverse tangent is computed.

Syntax: torch.atan(x, out=None)

Parameters:
x: Input tensor
name (optional): Output tensor

Return type: A tensor with the same type as that of x.

Code #1:

## Python3

 `# Importing the PyTorch library ` `import` `torch ` ` `  `# A constant tensor of size 6 ` `a ``=` `torch.FloatTensor([``1.0``, ``-``0.5``, ``3.4``, ``0.2``, ``0.0``, ``-``2``]) ` `print``(a) ` ` `  `# Applying the inverse tan function and ` `# storing the result in 'b' ` `b ``=` `torch.atan(a) ` `print``(b) `

Output:

```tensor([ 1.0000, -0.5000,  3.4000,  0.2000,  0.0000, -2.0000])
tensor([ 0.7854, -0.4636,  1.2847,  0.1974,  0.0000, -1.1071])
```

Code #2: Visualization

## Python3

 `# Importing the PyTorch library ` `import` `torch ` ` `  `# Importing the NumPy library ` `import` `numpy as np ` ` `  `# Importing the matplotlib.pyplot function ` `import` `matplotlib.pyplot as plt ` ` `  `# A vector of size 15 with values from -5 to 5 ` `a ``=` `np.linspace(``-``5``, ``5``, ``15``) ` ` `  `# Applying the inverse tangent function and ` `# storing the result in 'b' ` `b ``=` `torch.atan(torch.FloatTensor(a)) ` ` `  `print``(b) ` ` `  `# Plotting ` `plt.plot(a, b.numpy(), color ``=` `'red'``, marker ``=` `"o"``)  ` `plt.title(``"torch.atan"``)  ` `plt.xlabel(``"X"``)  ` `plt.ylabel(``"Y"``)  ` ` `  `plt.show() `

Output:

```tensor([-1.3734, -1.3416, -1.2978, -1.2341, -1.1342, -0.9601, -0.6202,  0.0000,
0.6202,  0.9601,  1.1342,  1.2341,  1.2978,  1.3416,  1.3734])
``` My Personal Notes arrow_drop_up
Recommended Articles
Page :
{"ft_lang_label":"__label__en","ft_lang_prob":0.57475394,"math_prob":0.8833897,"size":1640,"snap":"2022-40-2023-06","text_gpt3_token_len":553,"char_repetition_ratio":0.12224939,"word_repetition_ratio":0.091603056,"special_character_ratio":0.38231707,"punctuation_ratio":0.25714287,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9984012,"pos_list":[0,1,2],"im_url_duplicate_count":[null,7,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-09-30T07:10:31Z\",\"WARC-Record-ID\":\"<urn:uuid:70a7ef73-d6b0-481d-ae8a-62321bb06186>\",\"Content-Length\":\"163834\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:895f8559-7f38-4de9-9931-b941a00fb588>\",\"WARC-Concurrent-To\":\"<urn:uuid:6fcc0347-2de5-434c-bcfd-cf38a650df74>\",\"WARC-IP-Address\":\"44.228.100.190\",\"WARC-Target-URI\":\"https://origin.geeksforgeeks.org/python-pytorch-atan-method/\",\"WARC-Payload-Digest\":\"sha1:YZLVUWEMLJYQ4QJC6X7YVYITH4SN7QPX\",\"WARC-Block-Digest\":\"sha1:U46HXWTTWMJFZCPBTQK4SH2HEMVXHGE7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030335444.58_warc_CC-MAIN-20220930051717-20220930081717-00080.warc.gz\"}"}