s***@west.cmu.edu
2015-10-29 18:27:10 UTC
Hello,
I would like to know how to print variable inside the scan function.
For example, in lstm code, I would like to printout "c_t" for each step.
def one_lstm_step(x_t, h_tm1, c_tm1,
W_xi, W_hi, W_xf, W_hf, W_xc, W_hc, W_xo, W_ho):
i_t = T.nnet.sigmoid(theano.dot(x_t, W_xi) + theano.dot(h_tm1,
W_hi))
f_t = T.nnet.sigmoid(theano.dot(x_t, W_xf) + theano.dot(h_tm1,
W_hf))
c_t = f_t * c_tm1 + i_t * T.tanh(theano.dot(x_t, W_xc) +
theano.dot(h_tm1, W_hc) )
o_t = T.nnet.sigmoid(theano.dot(x_t, W_xo)+ theano.dot(h_tm1,
W_ho))
h_t = o_t * T.tanh(c_t)
return [h_t, c_t]
[self.h_vals, _, _, _], _ = theano.scan(fn=one_lstm_step,
sequences=self.input,
outputs_info=[self.h0, self.c0, self.a0_1, self.a0_2],
non_sequences=[self.W_xi, self.W_hi,
self.W_xf, self.W_hf,
self.W_xc, self.W_hc,
self.W_xo, self.W_ho],
n_steps=self.n_steps, strict=True, allow_gc=False)
Thank you.
I would like to know how to print variable inside the scan function.
For example, in lstm code, I would like to printout "c_t" for each step.
def one_lstm_step(x_t, h_tm1, c_tm1,
W_xi, W_hi, W_xf, W_hf, W_xc, W_hc, W_xo, W_ho):
i_t = T.nnet.sigmoid(theano.dot(x_t, W_xi) + theano.dot(h_tm1,
W_hi))
f_t = T.nnet.sigmoid(theano.dot(x_t, W_xf) + theano.dot(h_tm1,
W_hf))
c_t = f_t * c_tm1 + i_t * T.tanh(theano.dot(x_t, W_xc) +
theano.dot(h_tm1, W_hc) )
o_t = T.nnet.sigmoid(theano.dot(x_t, W_xo)+ theano.dot(h_tm1,
W_ho))
h_t = o_t * T.tanh(c_t)
return [h_t, c_t]
[self.h_vals, _, _, _], _ = theano.scan(fn=one_lstm_step,
sequences=self.input,
outputs_info=[self.h0, self.c0, self.a0_1, self.a0_2],
non_sequences=[self.W_xi, self.W_hi,
self.W_xf, self.W_hf,
self.W_xc, self.W_hc,
self.W_xo, self.W_ho],
n_steps=self.n_steps, strict=True, allow_gc=False)
Thank you.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.