We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c49115 commit 089fa11Copy full SHA for 089fa11
keras/layers/core.py
@@ -1121,7 +1121,25 @@ def output_shape(self):
1121
1122
def get_output(self, train=False):
1123
X = self.get_input(train)
1124
-
+ input_length = self.input_shape[1]
1125
+ if input_length and K._BACKEND == 'theano':
1126
+ import theano.tensor as T
1127
+ #X: (nb_samples, timesteps, input_dim)
1128
+ X = K.permute_dimensions(X, (1, 0, 2))
1129
+ #X: (timesteps, nb_samples, input_dim)
1130
+ W = [self.W] * input_length
1131
+ W = T.stack(*W)
1132
+ #W: (timesteps, input_dim, output_dim)
1133
+ z = T.batched_tensordot(X, W, axes=[(2), (1)])
1134
+ #z: (timesteps, nb_samples, output_dim)
1135
+ z = K.permute_dimensions(z, (1, 0, 2))
1136
+ #z: (nb_samples, timesteps, output_dim)
1137
+ b = [self.b] * input_length
1138
+ b = T.stack(*b)
1139
+ #b: (timesteps, output_dim)
1140
+ Y = self.activation(z + b)
1141
+ return Y
1142
+
1143
def step(x, states):
1144
output = K.dot(x, self.W) + self.b
1145
return output, []
0 commit comments