Hi everybody,
I am trying to calculate the product between a result of gradient and a
formula, like this:
T.grad(T.log(hl_mean).sum(), self.params, disconnected_inputs='warn') * T.
log(vn_mean).sum()
The error is:
theano.tensor.var.AsTensorError: ('Cannot convert [dot.0, Elemwise{mul}.0,
Elemwise{second,no_inplace}.0] to TensorType', <type 'list'>)
And to sum multiple results of gradient, like this:
(Rls, updates) = theano.scan(
calculate_Rl,
outputs_info=None,
non_sequences=v_input,
n_steps=hidden_sample_l
)
Rn = Rls.sum()
calculate_Rl returns a result of gradient:
def calculate_Rl(v_input):
# Sample a h_sample according to one v_input
_, hl_mean, hl_sample = self.sample_h_given_v(v_input)
# Calculate the probability of visible output according to h_sample
_, vn_mean = self.propdown(hl_sample)
# return T.grad(T.log(hl_mean).sum(), self.params,
disconnected_inputs='warn') \
# * T.log(vn_mean).sum() \
# + T.grad((T.log(vn_mean).sum()), self.params,
consider_constant=[vn_mean], disconnected_inputs='warn')
return T.grad(T.log(hl_mean).sum(), self.params,
disconnected_inputs='warn') * T.log(vn_mean).sum()
The error is:
AttributeError: 'list' object has no attribute 'sum'
So, the question is how to operate the results of gradients in Theano? Such
as calculating product or sum?
Any help is appreciated! Thanks!
--
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.