Skip to content

Commit d218600

Browse files
committed
Fixed transition to new words skipping probabilities
1 parent bf41c46 commit d218600

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/TokenPassing.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ def log(val):
5252
return float('-inf')
5353

5454

55-
def ctcTokenPassing(mat, classes, charWords):
55+
def ctcTokenPassing(mat, classes, charWords, blankIdx=None):
5656
"implements CTC Token Passing Algorithm as shown by Graves (Dissertation, p67-69)"
57-
blankIdx = len(classes)
57+
blankIdx = len(classes) if blankIdx is None else blankIdx
5858
maxT, _ = mat.shape
5959

6060
# special s index for beginning and end of word
@@ -107,7 +107,11 @@ def ctcTokenPassing(mat, classes, charWords):
107107
# 18-24
108108
s = 1
109109
while s <= len(wPrime):
110-
P = [toks.get(wIdx, s, t-1), toks.get(wIdx, s - 1, t - 1)]
110+
if s == 1:
111+
P = [toks.get(wIdx, s, t - 1), toks.get(wIdx, s - 1, t)]
112+
else:
113+
P = [toks.get(wIdx, s, t - 1), toks.get(wIdx, s - 1, t - 1)]
114+
111115
if wPrime[s-1] != blankIdx and s > 2 and wPrime[s - 2 - 1] != wPrime[s - 1]:
112116
tok = toks.get(wIdx, s - 2, t - 1)
113117
P.append(Token(tok.score, tok.history))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy