0
我有一个包含4个波段的RGBI图像,并希望能够使用张量流和深度学习将图像像素分为两类。 在训练数据中,每个像素被认为是具有4个值/特征的观察值作为图像强度。我用下面的函数来创建网络基于像素的图像分类的Tensorflow体系结构
def deep_learn(X,Y,X_test,Y_test):
net = input_data(shape=[None, 1,4])
net = tflearn.lstm(net, 128, return_seq=True)
net = tflearn.lstm(net, 128)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam',
loss='categorical_crossentropy', name="deep")
model = tflearn.DNN(net, tensorboard_verbose=2)
model.fit(X, Y, n_epoch=1, validation_set=0.1, show_metric=True,
snapshot_step=100)
# Save model when training is complete to a file
model.save("deep")
return model
,但我得到了以下错误
ValueError: Cannot feed value of shape (64, 4) for Tensor 'InputData/X:0', which has shape '(?, 1, 4)'
我不知道问题出在哪里。 使用深度神经网络与随机森林进行基于像素的分类有什么好处吗? 如果是的话,我该如何使用上述功能来做到这一点。
谢谢。
这解决了我的问题,但我有另外一个问题。训练模型后,p.array(model.predict(x_test))的结果仅为1。在一个例子中,我有4类对象,我期望该命令的结果是2到5之间的标签,但是预测函数的输出又是1.这可能是训练阶段的问题吗? – user2148425
NN的输出层是什么?如果你赞成/接受这个答案并且在一个新问题中提出这个问题,那么它是最好的,因为它是不相关的。另外,给我一个链接到这里的新问题 – martianwars
这里是链接http://stackoverflow.com/questions/41414305/wrong-output-of-prediction-function-in-tensorflow – user2148425