Tensorflow/TFLearn - ValueError: Cannot feed value of shape (64,) for Tensor 'target/Y:0', which has shape '(?, 1)'
Tensorflow/TFLearn - ValueError: Cannot feed value of shape (64,) for Tensor 'target/Y:0', which has shape '(?, 1)'
我一直在尝试使用 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: Cannot feed value of shape (64,) for Tensor 'target/Y:0', which has shape '(?, 1)'
我已经在 Whosebug 中搜索了我的问题,但 none 的答案对我有用。
我用的是Python3.6和TFlearn 0.3.2
你可以重塑标签
data, labels = load_csv('data.csv')
labels = np.reshape(labels, (-1, 1))
我一直在尝试使用 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: Cannot feed value of shape (64,) for Tensor 'target/Y:0', which has shape '(?, 1)'
我已经在 Whosebug 中搜索了我的问题,但 none 的答案对我有用。
我用的是Python3.6和TFlearn 0.3.2
你可以重塑标签
data, labels = load_csv('data.csv')
labels = np.reshape(labels, (-1, 1))