我是 tensorflow 的新手(1 天的经验)。
我正在尝试按照小代码创建一个基于 GRU 的简单 RNN,其单层和隐藏大小为 100,如下所示:
import pickle
import numpy as np
import pandas as pd
import tensorflow as tf
# parameters
batch_size = 50
hidden_size = 100
# create network graph
input_data = tf.placeholder(tf.int32, [batch_size])
output_data = tf.placeholder(tf.int32, [batch_size])
cell = tf.nn.rnn_cell.GRUCell(hidden_size)
initial_state = cell.zero_state(batch_size, tf.float32)
hidden_state = initial_state
output_of_cell, hidden_state = cell(input_data, hidden_state)
但我在最后一行收到以下错误(即调用cell()
)
Linear is expecting 2D arguments: [[50], [50, 100]]
我究竟做错了什么?