我一直试图使用tflearn和我自己的数据集来执行深度神经网络预测值。
我的神经网络基于Titanic的示例,但区别在于我将输出层从2更改为1并且激活了' softmax'到' lineal':
from tflearn.data_utils import load_csv
data, labels = load_csv('data.csv')
# Build neural network
net = tflearn.input_data(shape=[None, 5])
net = tflearn.fully_connected(net, 5, activation='sigmoid')
net = tflearn.fully_connected(net, 3, activation='sigmoid')
net = tflearn.fully_connected(net, 1, activation='linear')
net = tflearn.regression(net, optimizer='sgd', loss='mean_square', learning_rate=0.1, name='target')
# Define model
model = tflearn.DNN(net)
# Start training (apply gradient descent algorithm)
model.fit(data, labels,show_metric=True)
我收到以下错误:
ValueError:无法为Tensor' target / Y:0'提供形状值(64,),其形状为'(?,1)'
我已经在stackoverflow中搜索了我的问题,但没有一个答案适合我。
我使用Python 3.6和TFlearn 0.3.2
答案 0 :(得分:2)
你可以重塑标签
data, labels = load_csv('data.csv')
labels = np.reshape(labels, (-1, 1))