1

我有一些试图拟合函数的短代码。但我担心如何将数据提供给 tflearn rnn。

X 输入是一个 [45,1,8](45 个样本,4 个时间步长和 8 个特征)数组。因此,Y 输入应该是一个 [45,1,8] 数组,因为目标是最小化差异元素-明智的。

但是,尝试此操作时会引发以下错误

Cannot feed value of shape (45, 1, 8) for Tensor 'TargetsData/Y:0', which has shape '(?, 8)'

我似乎无法弄清楚我的错误。任何帮助,将不胜感激。

注:好像有人解决了类似的问题,但是看不懂答案 tensorflow/tflearn input shape

完整代码

def mod(rnn_output,state):
    Tau = tfl.variable(name='GRN', shape=[8],
                         initializer='uniform_scaling',
                         regularizer='L2')
    Timestep = tf.constant(6.0,shape=[8])
    one = tf.div(Timestep,Tau)
    two = rnn_output
    three = tf.mul(tf.sub(tf.ones(shape=[num_genes]),one),state)
    four = tf.mul(one,two)
    five = tf.add(four,three)
    return(five)
net = tfl.input_data(shape=[None,4,8])
out, state = tfl.layers.recurrent.simple_rnn(net,8,return_state=True
                                            ,name='RNN')
net = tfl.layers.core.custom_layer(out,mod,state=state)
net = tfl.layers.estimator.regression(net)
# Define model
model = tfl.DNN(net)
# Start training (apply gradient descent algorithm)
model.fit(train_x, train_y, n_epoch=10, batch_size=45, show_metric=True)
4

0 回答 0