MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / call

Method call

tensorflow/python/keras/layers/cudnn_recurrent.py:84–122  ·  view source on GitHub ↗
(self, inputs, mask=None, training=None, initial_state=None)

Source from the content-addressed store, hash-verified

82 self._vector_shape = constant_op.constant([-1])
83
84 def call(self, inputs, mask=None, training=None, initial_state=None):
85 if isinstance(mask, list):
86 mask = mask[0]
87 if mask is not None:
88 raise ValueError('Masking is not supported for CuDNN RNNs.')
89
90 # input shape: `(samples, time (padded with zeros), input_dim)`
91 # note that the .build() method of subclasses MUST define
92 # self.input_spec and self.state_spec with complete input shapes.
93 if isinstance(inputs, list):
94 initial_state = inputs[1:]
95 inputs = inputs[0]
96 elif initial_state is not None:
97 pass
98 elif self.stateful:
99 initial_state = self.states
100 else:
101 initial_state = self.get_initial_state(inputs)
102
103 if len(initial_state) != len(self.states):
104 raise ValueError('Layer has ' + str(len(self.states)) +
105 ' states but was passed ' + str(len(initial_state)) +
106 ' initial states.')
107
108 if self.go_backwards:
109 # Reverse time axis.
110 inputs = K.reverse(inputs, 1)
111 output, states = self._process_batch(inputs, initial_state)
112
113 if self.stateful:
114 updates = []
115 for i in range(len(states)):
116 updates.append(state_ops.assign(self.states[i], states[i]))
117 self.add_update(updates)
118
119 if self.return_state:
120 return [output] + states
121 else:
122 return output
123
124 def get_config(self):
125 config = {

Callers

nothing calls this directly

Calls 7

add_updateMethod · 0.80
rangeFunction · 0.50
get_initial_stateMethod · 0.45
reverseMethod · 0.45
_process_batchMethod · 0.45
appendMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected