This post explains how to calculate `Cosine Similarity`

in `PyTorch`

.
`torch.nn.functional`

module provides `cosine_similarity`

method for calculating `Cosine Similarity`

```
import torch
import torch.nn.functional as F
```

```
tensor1 = torch.randn(50)
tensor2 = torch.randn(50)
```

`Cosine Similarity`

```
cosine_similarity_value = F.cosine_similarity(tensor1, tensor2, dim=0)
print(cosine_similarity_value)
#### Output ####
tensor(-0.2427)
```

Categories: PyTorch

list_physical_devices
functional model
Crossentropy
flatten()
rust read file
rust cargo
compile rust
install rust
nodejs installation
Jenkins installation
Docker installation
cuda-version
Boston-Dataset
tf.keras.utils
String Operators
test command
Docker-Installation
batch_flatten
BinaryCrossEntropy