Remove gradients as a class variable in CTC GPU Op

上级 95cb40e1
...@@ -95,17 +95,17 @@ class GpuConnectionistTemporalClassification(gof.COp): ...@@ -95,17 +95,17 @@ class GpuConnectionistTemporalClassification(gof.COp):
outputs = [costs] outputs = [costs]
if self.compute_grad: if self.compute_grad:
self.gradients = GpuArrayType(dtype='float32', gradients = GpuArrayType(dtype='float32',
broadcastable=(False, False, False,), broadcastable=(False, False, False,),
context_name=context_name)() context_name=context_name)()
outputs += [self.gradients] outputs += [gradients]
return theano.Apply(self, inputs=[t_activations, t_labels, t_input_lengths], return theano.Apply(self, inputs=[t_activations, t_labels, t_input_lengths],
outputs=outputs) outputs=outputs)
def L_op(self, inputs, outputs, output_grads): def L_op(self, inputs, outputs, output_grads):
# Gradients computed by Op # Gradients computed by Op
gradients = self.gradients gradients = outputs[1]
assert gradients is not None assert gradients is not None
# Gradients of original function, to compose chain rule # Gradients of original function, to compose chain rule
...@@ -134,7 +134,8 @@ def gpu_ctc(activations, labels, input_lengths): ...@@ -134,7 +134,8 @@ def gpu_ctc(activations, labels, input_lengths):
to the fastest changing dimension, from left to right. In this case, to the fastest changing dimension, from left to right. In this case,
p is the fastest changing dimension. p is the fastest changing dimension.
labels labels
A 1-D tensor of all the labels for the minibatch. A 2-D tensor of all the labels for the minibatch. Each row contains
a sequence of target labels.
input_lengths input_lengths
A 1-D tensor with the number of time steps for each sequence in A 1-D tensor with the number of time steps for each sequence in
the minibatch. the minibatch.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论