编译安装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()
本文详细介绍了如何编译安装 PyTorch 的 CTC Loss,并解决在墙内环境下遇到的 fatal error: 'torch/extension.h' No such file or directory 错误。提供了解决方案的 GitHub 链接,并分享了适用于 PyTorch 1.0 版本的代码示例。
3171

被折叠的 条评论
为什么被折叠?



