【发布时间】:2017-06-17 11:57:38
【问题描述】:
我有两个数据集,就像:
input:
array([[[ 0.99309823],
...
[ 0. ]]])
shape : (1, 2501)
output:
array([[0, 0, 0, ..., 0, 0, 1],
...,
[0, 0, 0, ..., 0, 0, 0]])
shape : (2501, 9)
我用 TFLearn 处理它;作为
input_layer = tflearn.input_data(shape=[None,2501])
hidden1 = tflearn.fully_connected(input_layer,1205,activation='ReLU', regularizer='L2', weight_decay=0.001)
dropout1 = tflearn.dropout(hidden1,0.8)
hidden2 = tflearn.fully_connected(dropout1,1205,activation='ReLU', regularizer='L2', weight_decay=0.001)
dropout2 = tflearn.dropout(hidden2,0.8)
softmax = tflearn.fully_connected(dropout2,9,activation='softmax')
# Regression with SGD
sgd = tflearn.SGD(learning_rate=0.1,lr_decay=0.96, decay_step=1000)
top_k=tflearn.metrics.Top_k(3)
net = tflearn.regression(softmax,optimizer=sgd,metric=top_k,loss='categorical_crossentropy')
model = tflearn.DNN(net)
model.fit(input,output,n_epoch=10,show_metric=True, run_id='dense_model')
它有效,但不是我想要的方式。这是一个 DNN 模型。我希望当我输入 0.95 时,模型必须给我相应的预测,例如 [0,0,0,0,0,0,0,0,1]。但是,当我想输入 0.95 时,它会说,
ValueError: Cannot feed value of shape (1,) for Tensor 'InputData/X:0', which has shape '(?, 2501)'
当我试图理解时,我意识到我需要 (1,2501) 个形状的数据来预测我的错误模型。
我想要的是输入中的每个元素,预测输出中的相应元素。如您所见,在实例数据集中,
对于[0.99309823],对应的输出是[0,0,0,0,0,0,0,0,1]。我希望 tflearn 像这样训练自己。
我可能有错误的结构化数据或模型(可能是数据集),我解释了所有事情,我需要帮助我真的疯了。
【问题讨论】:
标签: python tensorflow neural-network deep-learning tflearn