Filter löschen
Filter löschen

How to bypass automatic differentiation?

3 Ansichten (letzte 30 Tage)
sunny Yang
sunny Yang am 21 Feb. 2020
Kommentiert: Xuefu Dong am 5 Jul. 2023
I'm trying to implement a simple speech recognition by Deep Learning Toolbox.
the network receives a piece of spectrogram,and it gives the possibility of each phone(ɔi au əu,。。。 etc) at each timetick.
I have some speech sentences recording & corresponding phonetic sign,but I must use CTC(Connectionist Temporal Classification) algorithm to match the phoentic sequence onto the possibility sequence outputed by CNN.
But the problem is:
CTC algorithm contains several nesting looped process,making it extremely unfriendly to automatic differentiation.A typical CTC call takes less then 0.1sec,but it takes 20 seconds to finish under dlfeval().
CTC algorithm gives a relation index,like(#1~#5 output of NN-> first sign in Supervise output,#6~#7 -> second sign...etc ),
On the other words,Loss = sum( [Neural_Network_Outp_vector - Supervise(CTC_relation_index) ].^2,'all'),and (CTC relation index) is a constant indexing vector here .
So,How to bypass the automatic differentiation here,to let the CTC call gives the relation index quickly?
Now I use this method:call neural network forward() and CTC outside dlfeval() to get the relation index ,and send both the input and this index into dlfeval(),forward() again to get the gradient.
Can I do forward() once?

Antworten (1)

sunny Yang
sunny Yang am 16 Apr. 2020
Bearbeitet: sunny Yang am 16 Apr. 2020
use extractdata() to bypass grad:
x=dlarray(1);
[y,Y,dy_dx,dY_dx] = dlfeval(@goat,x)
% y=Y=4
dy_dx=4=d(x^2+2*x+1)/dx|x=1
dY_dx=2=d(x^2+1)/dx|x=1
function [y,Y,dy_dx,dY_dx] = goat(x)
X=x.extractdata();
y=x^2+2*x+1;
Y = x^2+2*X+1;
dy_dx = dlgradient(y,x);
dY_dx = dlgradient(Y,x);
end
better
  1 Kommentar
Xuefu Dong
Xuefu Dong am 5 Jul. 2023
Thanks a lot! do you mind if I ask some questions regarding CTC in matlab?

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by