tensorflow - 如何使用 tensorflow SimpleRNNCell 处理批处理数据集?
问题描述
我正在使用 Tensorflow 创建 Seq2Seq 模型。我尝试使用小批量处理数据集。当我使用batch()
Tensorflow 中的方法构建数据集时,数据集形状变为(None,10)
. 但是,当向其提供数据时SimpleRNNCell
会引发错误:
ValueError: Shape must be rank 2 but is rank 1 for 'simple_rnn_cell/MatMul_1' (op: 'MatMul') with input shapes: [10], [10,10].
代码是这样的:
def decoder(self, input_x, real_y, encoder_outputs, training=False):
decoder_state, cell_states = encoder_outputs, []
predict_shape = (5, 1)
output = tf.convert_to_tensor(np.zeros(predict_shape), dtype=tf.float32)
for x in range(self.max_output):
# below code raises error, here output and decoder_state shape is (5, 1) (?, 10)
output, decoder_state = self.decoder_rnn(output, decoder_state)
解决方案
推荐阅读
- json - 需要在scala中将字符串转换为Json对象
- firebase - Firestore 数据建模文章和类别
- r - 在“R”中解析 JSON
- swift - Swift:内存压力事件 2 vm 0
- javascript - Axios 没有在 401 错误响应中写入状态 401
- php - 在我追加新行后,select2 不起作用
- sql-server - COLUMNS_UPDATED() 从表中间的列开始跳过一点
- python - 从日志文件中删除不需要的字符
- azure - Azure Devops 发布管道 - Azure 应用服务文件未更新
- python - 我需要一个简单的条形码扫描仪,可以将 barodes 值保存在变量中