Tensorflow 使用tf.nn.dynamic\u rnn,但最终状态没有c和h

Tensorflow 使用tf.nn.dynamic\u rnn,但最终状态没有c和h,tensorflow,recurrent-neural-network,tensor,Tensorflow,Recurrent Neural Network,Tensor,我正在使用tensorflow,我想用RNN运行一个程序,但我得到了以下错误: a=self._encoder_final_state[0].c AttributeError: 'Tensor' object has no attribute 'c' 程序是这样的: self._encoder_cells = build_rnn_layers( cell_type=self._hparams.cell_type, num_units_per_layer=self._num_un

我正在使用tensorflow,我想用RNN运行一个程序,但我得到了以下错误:

a=self._encoder_final_state[0].c
AttributeError: 'Tensor' object has no attribute 'c'
程序是这样的:

self._encoder_cells = build_rnn_layers(
    cell_type=self._hparams.cell_type,
    num_units_per_layer=self._num_units_per_layer,
    use_dropout=self._hparams.use_dropout,
    dropout_probability=self._hparams.dropout_probability,
    mode=self._mode,
    residual_connections=self._hparams.residual_encoder,
    highway_connections=self._hparams.highway_encoder,
    dtype=self._hparams.dtype,
)

self._encoder_outputs, self._encoder_final_state = tf.nn.dynamic_rnn(
    cell=self._encoder_cells,
    inputs=encoder_inputs,
    sequence_length=self._inputs_len,
    parallel_iterations=self._hparams.batch_size[0 if self._mode == 'train' else 1],
    swap_memory=False,
    dtype=self._hparams.dtype,
    scope=scope,
)
a=self._encoder_final_state[0].c
从动态链接中:

如果单元格是LSTMCells,则状态将是包含 每个单元格的LSTMStateTuple

您可以看到,LSTMStateTuple确实具有所需的c和h属性

不幸的是,你的代码没有给我任何线索,你正在使用什么样的细胞,但显然,他们不是lstmcell。因此,我不能给你任何比改用LSTMCells更好的建议