Pytorch 中triplet loss的写法
来源:互联网 发布:高中化学软件下载 编辑:程序博客网 时间:2024/05/22 13:56
triplet loss
在Pytorch中有一个类,已经定义好了triplet loss的criterion, class TripletMarginLoss(Module):
class TripletMarginLoss(Module): r"""Creates a criterion that measures the triplet loss given an input tensors x1, x2, x3 and a margin with a value greater than 0. This is used for measuring a relative similarity between samples. A triplet is composed by `a`, `p` and `n`: anchor, positive examples and negative example respectively. The shape of all input variables should be :math:`(N, D)`. The distance swap is described in detail in the paper `Learning shallow convolutional feature descriptors with triplet losses`_ by V. Balntas, E. Riba et al. Args: anchor: anchor input tensor positive: positive input tensor negative: negative input tensor p: the norm degree. Default: 2 Shape: - Input: :math:`(N, D)` where `D = vector dimension` - Output: :math:`(N, 1)`
使用示例:
>>> triplet_loss = nn.TripletMarginLoss(margin=1.0, p=2) >>> input1 = autograd.Variable(torch.randn(100, 128)) >>> input2 = autograd.Variable(torch.randn(100, 128)) >>> input3 = autograd.Variable(torch.randn(100, 128)) >>> output = triplet_loss(input1, input2, input3) >>> output.backward()
参考网址
https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/loss.py
阅读全文
0 0
- Pytorch 中triplet loss的写法
- Triplet Loss
- 在caffe中添加triplet loss layer
- triplet loss的原理及caffe代码
- Caffe中增加新的layer以及Caffe中triplet loss layer的实现
- 如何在caffe中增加layer以及caffe中triplet loss layer的实现
- 如何在caffe中增加layer以及caffe中triplet loss layer的实现
- 如何在caffe中增加layer以及caffe中triplet loss layer的实现
- 如何在caffe中增加layer以及caffe中triplet loss layer的实现
- caffe中添加自己的layer(以triplet loss为例)
- Torch 中添加自己的 nn Modules:以添加 Dropout、 Triplet Loss 为例
- 在 caffe 中添加 FaceNet 中 Triplet Loss Layer
- matlab---triplet loss
- triplet loss layer原理
- Triplet Loss及其梯度
- Triplet Loss(未开始)
- triplet loss总结
- pytorch loss function 总结
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(7)-MVC与EasyUI DataGrid
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(17)-LinQ动态排序
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(18)-权限管理系统-表数据
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(19)-权限管理系统-用户登录
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(20)-权限管理系统-根据权限获取菜单
- Pytorch 中triplet loss的写法
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(21)-权限管理系统-跑通整个系统
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(22)-权限管理系统-模块导航制作
- 桂林电子科技大学linux下使用桂电出校器
- ASP.NET MVC5+EF6+EasyUI 后台管理系统-分配角色给用户
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(27)-权限管理系统-分配用户给角色
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(28)-系统小结
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(29)-T4模版
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(30)-本地化(多语言)