ctc loss解决问题:src/binding.cpp:6:29: fatal error: torch/extension.h: No such file or directory 墙内没有

 

编译安装pytorch的 ctc loss 使用仓库:

https://github.com/SeanNaren/warp-ctc

 

会遇到问题:墙内没有解决方案:

src/binding.cpp:6:29: fatal error: torch/extension.h: No such file or directory
compilation terminated.

 

解决参考帖子:(我当时百度搜不出来。。。)

https://github.com/SeanNaren/warp-ctc/issues/101

OK, this seems to be related to PyTorch 1.0. If you are using PyTorch 0.4, just revert this repo to the previous commit:
git checkout ac045b6072b9bc3454fb9f9f17674f0d59373789
and then it will work.

最后放个测试代码:

import torch
from warpctc_pytorch import CTCLoss
ctc_loss = CTCLoss()
# expected shape of seqLength x batchSize x alphabet_size
probs = torch.FloatTensor([[[0.1, 0.6, 0.1, 0.1, 0.1], [0.1, 0.1, 0.6, 0.1, 0.1]]]).transpose(0, 1).contiguous()
labels = torch.IntTensor([1, 2])
label_sizes = torch.IntTensor([2])
probs_sizes = torch.IntTensor([2])
probs.requires_grad_(True)  # tells autograd to compute gradients for probs
cost = ctc_loss(probs, labels, probs_sizes, label_sizes)
cost.backward()

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值