Giter Club home page Giter Club logo

Comments (3)

discort avatar discort commented on July 17, 2024

But a simple example from docs works as expected

out = 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).requires_grad_(True)
print(out.shape)
labels = torch.IntTensor([1, 2])
label_lengths = torch.IntTensor([2])
input_lengths = torch.IntTensor([2])

warp_ctc = CTCLoss(size_average=True)
torch_ctc = nn.CTCLoss(reduction='sum')
loss1 = warp_ctc(out, labels, input_lengths, label_lengths)
print(loss1)
loss2 = torch_ctc(out.log_softmax(2), labels, input_lengths, label_lengths)
print(loss2)

out

torch.Size([2, 1, 5])
tensor([2.4629], grad_fn=<_CTCBackward>)
tensor(2.4629, grad_fn=<SumBackward0>)

@SeanNaren any ideas about the origins of double free or corruption (!prev) (cpu) or zeros on cuda?

from warp-ctc.

Zhang-O avatar Zhang-O commented on July 17, 2024

import torch
import torch.nn as nn
from warpctc_pytorch import CTCLoss

out = torch.randn(368, 2, 29)
input_lengths = torch.IntTensor([119, 179])
labels = torch.randint(1, 27, size=(148,)).int()
label_lengths = torch.IntTensor([59, 89])

warp_ctc = CTCLoss()
torch_ctc = nn.CTCLoss(reduction='sum')

loss1 = warp_ctc(out, labels, input_lengths, label_lengths)
print(loss1)

loss2 = torch_ctc(out.log_softmax(2), labels, input_lengths, label_lengths)
print(loss2)

from warp-ctc.

Zhang-O avatar Zhang-O commented on July 17, 2024

remember follows:
torch.tensor([119, 179]) returns torch.int64 , not torch.int32
torch.randint(1, 27, size=(148,)) returns torch.int64 , not torch.int32

from warp-ctc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.