Comments (7)
You can use ctc_layer and ctc_error_evaluator as follows. Note, in consideration of the ‘blank’ label is needed by CTC, the size of ctc_layer and its input layer should be 134 (133 + 1). The 'blank' is the last category index by default, namely 133. We also integrate warp-CTC before, which may be merged later.
... # omit the previous content
output = fc_layer(input=inputs, size=134, act=SoftmaxActivation())
label = data_layer('label', class_dim)
ctc = ctc_layer(input=output, label=label, 134)
eval = ctc_error_evaluator(input=output, label=label)
outputs(ctc)
from paddle.
@qingqing01 Many thanks.
from paddle.
@F0REacH I forget to remind you to update the code.
from paddle.
@qingqing01 I saw commit 9f3cbed fixed ctc issues. Nice work
from paddle.
Hi, @qingqing01
I've pulled the latest code and changed the model as you suggested:
def stacked_gru_net_with_ctc(input_dim=24,
class_dim=133,
hid_dim=129,
stacked_num=3,
is_predict=False):
"""
"""
assert stacked_num % 2 == 1
linear = LinearActivation()
data = data_layer("word", input_dim)
fc1 = fc_layer(input=data, size=hid_dim, act=linear)
gru1 = grumemory(input=fc1)
inputs = [fc1, gru1]
for i in range(2, stacked_num + 1):
fc = fc_layer(input=inputs, size=hid_dim, act=linear)
gru = grumemory(input=fc, reverse=(i % 2) == 0)
inputs = [fc, gru]
output = fc_layer(input=inputs, size=class_dim+1, act=SoftmaxActivation())
label = data_layer('label', class_dim)
ctc = ctc_layer(input=output, label=label, size=class_dim+1)
if is_predict:
outputs(output)
else:
eval = ctc_error_evaluator(input=output, label=label)
outputs(ctc)
But somehow started getting segmentation fault error:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000b1ed66 in __gnu_cxx::__ops::_Iter_less_iter::operator()<float*, float*> (this=0x7ffcb7b25980, __it1=0x21cc21000, __it2=0x21cc21004) at /opt/gcc/include/c++/4.9.4/bits/predefined_ops.h:42
42 { return *__it1 < *__it2; }
[Current thread is 1 (Thread 0x7f5fe144f800 (LWP 8836))]
(gdb) bt
#0 0x0000000000b1ed66 in __gnu_cxx::__ops::_Iter_less_iter::operator()<float*, float*> (this=0x7ffcb7b25980, __it1=0x21cc21000, __it2=0x21cc21004) at /opt/gcc/include/c++/4.9.4/bits/predefined_ops.h:42
#1 0x0000000000b1e9ed in std::__max_element<float*, __gnu_cxx::__ops::_Iter_less_iter> (__first=0x21cc21004, __last=0x21cc21218, __comp=...) at /opt/gcc/include/c++/4.9.4/bits/stl_algo.h:5474
#2 0x0000000000b1e84c in std::max_element<float*> (__first=0x21cc21000, __last=0x21cc21218) at /opt/gcc/include/c++/4.9.4/bits/stl_algo.h:5497
#3 0x0000000000b1d1dc in paddle::CTCErrorEvaluator::bestLabelSeq (this=0x13a573f0) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/gserver/evaluators/CTCErrorEvaluator.cpp:52
#4 0x0000000000b1dc29 in paddle::CTCErrorEvaluator::editDistance (this=0x13a573f0, output=0x219046ce8, numTimes=120314, numClasses=134, labels=0x2049e5928, labelsLen=61) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/gserver/evaluators/CTCErrorEvaluator.cpp:175
#5 0x0000000000b1e152 in paddle::CTCErrorEvaluator::evalImp (this=0x13a573f0, arguments=std::vector of length 2, capacity 2 = {...}) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/gserver/evaluators/CTCErrorEvaluator.cpp:212
#6 0x0000000000affcae in paddle::Evaluator::eval (this=0x13a573f0, nn=...) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/gserver/evaluators/Evaluator.cpp:32
#7 0x0000000000b1e23e in paddle::CTCErrorEvaluator::eval (this=0x13a573f0, nn=...) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/gserver/evaluators/CTCErrorEvaluator.cpp:221
#8 0x0000000000ad6e4e in paddle::CombinedEvaluator::eval (this=0x13a57340, nn=...) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/gserver/gradientmachines/NeuralNetwork.cpp:321
#9 0x0000000000ad4f44 in paddle::NeuralNetwork::eval (this=0x136f0e70, evaluator=0x13a57340) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/gserver/gradientmachines/NeuralNetwork.cpp:379
#10 0x0000000000bc461e in paddle::TrainerInternal::trainOneBatch (this=0x7ffcb7b26a30, batchId=0, dataBatch=...) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/trainer/TrainerInternal.cpp:143
#11 0x0000000000bbe532 in paddle::Trainer::trainOnePass (this=0x7ffcb7b26980, passId=0) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/trainer/Trainer.cpp:434
#12 0x0000000000bbd1e0 in paddle::Trainer::train (this=0x7ffcb7b26980, numPasses=100000) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/trainer/Trainer.cpp:280
#13 0x00000000009f2761 in main (argc=12, argv=0x7ffcb7b27518) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/trainer/TrainerMain.cpp:100
(gdb) frame 3
#3 0x0000000000b1d1dc in paddle::CTCErrorEvaluator::bestLabelSeq (this=0x13a573f0) at /home/foreach/SOFT/BAIDU/PADDLE/Paddle/paddle/gserver/evaluators/CTCErrorEvaluator.cpp:52
52 acts + (i + 1) * numClasses_) -
(gdb) info locals
i = 117089
path = std::vector of length 117089, capacity 131072 = {118, 60, 7, 7, 97, 40, 53, 40, 53, 53, 53, 7, 7, 7, 7, 7, 44, 44, 132, 7, 7, 53, 53, 53, 53, 53, 53, 53, 53, 97, 97, 7, 53, 53, 40, 53, 53, 17, 7, 7, 44, 44, 53, 53, 53, 22, 7, 44, 44, 17, 7, 87, 87, 53, 53, 53, 53, 53, 53, 53,
53, 53, 53, 53, 53, 53, 7, 51, 53, 53, 53, 129, 129, 48, 48, 48, 48, 48, 112, 112, 2, 47, 31, 60, 48, 48, 48, 20, 60, 60, 60, 60, 60, 6, 48, 48, 48, 48, 39, 39, 60, 127, 48, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 6, 127, 127, 127, 127, 127, 127, 60,
127, 127, 60, 6, 38, 118, 38, 84, 84, 84, 84, 39, 39, 127, 127, 127, 127, 127, 2, 54, 54, 47, 47, 47, 48, 48, 48, 48, 48, 15, 48, 48, 48, 47, 47, 47, 48, 47, 48, 48, 48, 48, 48, 47, 48, 48, 48, 112, 97, 97, 6, 39, 6, 21, 6, 21, 39, 127, 48, 48, 54, 54, 48, 48, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127...}
acts = 0x219046ce8
(gdb) p numClasses_
$1 = 134
(gdb) p numTimes_
$2 = 120314
from paddle.
Hi, please refer to the changes in paddle/gserver/evaluators/CTCErrorEvaluator.cpp
at this pull https://github.com/baidu/Paddle/pull/82/files
from paddle.
Thanks, @qingqing01 with pull #82 all is OK.
from paddle.
Related Issues (20)
- Fail to fscanf: Success [0] HOT 1
- 有没有jetpack6.0的python安装包,在jetpack5中,目前的cuda,cudnn版本已经不兼容paddle了 HOT 1
- jetson上安装paddle_gpu HOT 3
- 在centos上安装paddle==2.6.1版本出现Illegal instruction (core dumped)错误,用dmesg -T查看有下面错误,是什么原因?谢 HOT 12
- nn.Linear的输出与pytorch不一致 HOT 1
- windows下python3.10编译cuda12.1版本的2.6.1paddle失败 HOT 12
- while_loop报错 HOT 4
- LSTM API could_use_cudnn 段错误 HOT 5
- npu下import paddlenlp报错:No module named 'paddle.nn.layer.layers' HOT 2
- paddle.signal.stft 计算后,paddle.as_real 计算错误 HOT 2
- paddle.nn.MaxPool2D没有实现dilation参数 HOT 1
- docker镜像无法使用 HOT 1
- [Type Hints] 为公开 API 标注类型提示信息 HOT 90
- 安装Paddle后import paddle报错 HOT 5
- MacOS 10.15安装paddle cpu版本后import paddle报错 HOT 2
- [Targeting 2024 Sep.] paddle.distributed.new_group的rank與world_size在group size=1時會輸出-1 HOT 4
- 官网映射文档develop版本无法正常显示,挂了很长时间了 HOT 2
- Inadequate Validation for 'chunks' Parameter in `paddle.chunk` led to Aborted. HOT 2
- Segmentation fault and Aborted in `paddle.index_fill_`. HOT 4
- 反馈部分API文档中的bug和docs仓库下的rst文档bug HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paddle.