#np.random.seed(seed=123)

tX = T.ftensor3('tX')
tH = T.fmatrix('tH')
tm = T.fmatrix('tm')
ty = T.imatrix('ty')

classifier = E_RNN(seqs=tX, h0s=tH, masks=tm, dim_x=909, dim_h=21, dim_y=21, wt_y=wt_y, Wx=Wx, Wh=Wh, W=W, bh=bh, b=b)
#classifier = E_RNN(seqs=tX, h0s=tH, masks=tm, dim_x=909, dim_h=21, dim_y=21, wt_y=wt_y)

tcost = classifier.negative_log_likelihood(ty)
tpred = classifier.pred_grosslabel()
terr = classifier.errors(ty)
tgrads = T.grad(cost=tcost, wrt=classifier.params)

f_grad_shared, f_update = adadelta(classifier.params, tgrads, tX, tH, tm, ty, tcost)
f_pred_gross = theano.function([tX, tH, tm], tpred,
                         on_unused_input='ignore')
f_pred_err = theano.function([tX, tH, tm, ty], terr,

                             on_unused_input='ignore')

f_watch = theano.function([tX, tH, tm, ty], classifier.watch_var(ty),
                          on_unused_input='ignore')

# endregion

# region Training Process
print 'Training...'

train_sz = X.shape[0]
Esempio n. 2
0
                   dim_h=21,
                   dim_y=21,
                   wt_y=wt_y,
                   Wx=Wx,
                   Wh=Wh,
                   W=W,
                   bh=bh,
                   b=b)
#classifier = E_RNN(seqs=tX, h0s=tH, masks=tm, dim_x=909, dim_h=21, dim_y=21, wt_y=wt_y)

tcost = classifier.negative_log_likelihood(ty)
tpred = classifier.pred_grosslabel()
terr = classifier.errors(ty)
tgrads = T.grad(cost=tcost, wrt=classifier.params)

f_grad_shared, f_update = adadelta(classifier.params, tgrads, tX, tH, tm, ty,
                                   tcost)
f_pred_gross = theano.function([tX, tH, tm], tpred, on_unused_input='ignore')
f_pred_err = theano.function([tX, tH, tm, ty], terr, on_unused_input='ignore')

f_watch = theano.function([tX, tH, tm, ty],
                          classifier.watch_var(ty),
                          on_unused_input='ignore')

# endregion

# region Training Process
print 'Training...'

train_sz = X.shape[0]
train_batch_sz = X.shape[0]
train_batch_n = train_sz / train_batch_sz