我有一些尝试适合功能的短代码。但我担心如何将数据提供给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)