用法:
class torch.nn.CosineSimilarity(dim=1, eps=1e-08)
返回
dim
计算。 和 之间的余弦相似度,沿- 形状:
输入 1:
dim
其中 D 位于位置- 输入 2:
dim
匹配 x1 大小, ,与 x1 相同的维度数,在维度 并且可以在其他维度上用 x1 广播。
- 输入 2:
输出:
- 例子::
>>> input1 = torch.randn(100, 128) >>> input2 = torch.randn(100, 128) >>> cos = nn.CosineSimilarity(dim=1, eps=1e-6) >>> output = cos(input1, input2)
相关用法
- Python torch.nn.ConstantPad3d用法及代码示例
- Python torch.nn.Conv3d用法及代码示例
- Python torch.nn.ConvTranspose2d用法及代码示例
- Python torch.nn.ConvTranspose3d用法及代码示例
- Python torch.nn.Conv1d用法及代码示例
- Python torch.nn.ConstantPad2d用法及代码示例
- Python torch.nn.Conv2d用法及代码示例
- Python torch.nn.ConstantPad1d用法及代码示例
- Python torch.nn.CELU用法及代码示例
- Python torch.nn.ChannelShuffle用法及代码示例
- Python torch.nn.CTCLoss用法及代码示例
- Python torch.nn.CrossEntropyLoss用法及代码示例
- Python torch.nn.InstanceNorm3d用法及代码示例
- Python torch.nn.quantized.dynamic.LSTM用法及代码示例
- Python torch.nn.EmbeddingBag用法及代码示例
- Python torch.nn.Module.register_forward_hook用法及代码示例
- Python torch.nn.AvgPool2d用法及代码示例
- Python torch.nn.PixelShuffle用法及代码示例
- Python torch.nn.Hardsigmoid用法及代码示例
- Python torch.nn.GLU用法及代码示例
- Python torch.nn.functional.conv1d用法及代码示例
- Python torch.nn.Identity用法及代码示例
- Python torch.nn.Sigmoid用法及代码示例
- Python torch.nn.utils.spectral_norm用法及代码示例
- Python torch.nn.utils.prune.custom_from_mask用法及代码示例
注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torch.nn.CosineSimilarity。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。