我正在尝试实现此LSTM cell,但不断收到以下错误。我运行它的代码是:
lstm_cell =rnn.TimeFreqLSTMCell(n_hidden, use_peepholes=True, feature_size= 22, forget_bias=1.0)
outputs, states = rnn.static_rnn(lstm_cell, x, dtype=tf.float32)
第二行发生错误。错误跟踪在下面,我得知错误是由于数据类型不匹配而无法确定如何修复错误。
> 44 pred = RNN(x, weights, biases,n_steps)
45 cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=pred, labels=y))
46 optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)
<ipython-input-53-80cdb90dd338> in RNN(x, weights, biases, n_steps)
13 elif cellType == "TimeFreqLSTMCell":
14 lstm_cell =rnn.TimeFreqLSTMCell(n_hidden, use_peepholes=True, feature_size= 22, forget_bias=1.0)
---> 15 outputs, states = rnn.static_rnn(lstm_cell, x, dtype=tf.float32)
16 elif cellType == "GridLSTMCell":
17 lstm_cell =rnn.GridLSTMCell(n_hidden, forget_bias=1.0)
~/.local/lib/python3.5/site-packages/tensorflow/python/ops/rnn.py in static_rnn(cell, inputs, initial_state, dtype, sequence_length, scope)
1210 state_size=cell.state_size)
1211 else:
-> 1212 (output, state) = call_cell()
1213
1214 outputs.append(output)
~/.local/lib/python3.5/site-packages/tensorflow/python/ops/rnn.py in <lambda>()
1197 varscope.reuse_variables()
1198 # pylint: disable=cell-var-from-loop
-> 1199 call_cell = lambda: cell(input_, state)
1200 # pylint: enable=cell-var-from-loop
1201 if sequence_length is not None:
~/.local/lib/python3.5/site-packages/tensorflow/python/ops/rnn_cell_impl.py in __call__(self, inputs, state, scope)
178 with vs.variable_scope(vs.get_variable_scope(),
179 custom_getter=self._rnn_get_variable):
--> 180 return super(RNNCell, self).__call__(inputs, state)
181
182 def _rnn_get_variable(self, getter, *args, **kwargs):
~/.local/lib/python3.5/site-packages/tensorflow/python/layers/base.py in __call__(self, inputs, *args, **kwargs)
439 # Check input assumptions set after layer building, e.g. input shape.
440 self._assert_input_compatibility(inputs)
--> 441 outputs = self.call(inputs, *args, **kwargs)
442
443 # Apply activity regularization.
~/.local/lib/python3.5/site-packages/tensorflow/contrib/rnn/python/ops/rnn_cell.py in call(self, inputs, state)
336 tanh = math_ops.tanh
337
--> 338 freq_inputs = self._make_tf_features(inputs)
339 dtype = inputs.dtype
340 actual_input_size = freq_inputs[0].get_shape().as_list()[1]
~/.local/lib/python3.5/site-packages/tensorflow/contrib/rnn/python/ops/rnn_cell.py in _make_tf_features(self, input_feat)
415 raise ValueError("Cannot infer input_size from static shape inference.")
416 num_feats = int((input_size - self._feature_size) / (
--> 417 self._frequency_skip)) + 1
418 freq_inputs = []
419 for f in range(num_feats):
TypeError: unsupported operand type(s) for /: 'int' and 'NoneType'