我正在使用由tflearn
提供的DNN从一些数据中学习。我data
变量的(6605, 32)
的形状和我labels
数据具有(6605,)
,我在下面的代码(6605, 1)
重塑形状......形状必须是1级,但是是2级tflearn错误
# Target label used for training
labels = np.array(data[label], dtype=np.float32)
# Reshape target label from (6605,) to (6605, 1)
labels = tf.reshape(labels, shape=[-1, 1])
# Data for training minus the target label.
data = np.array(data.drop(label, axis=1), dtype=np.float32)
# DNN
net = tflearn.input_data(shape=[None, 32])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 1, activation='softmax')
net = tflearn.regression(net)
# Define model.
model = tflearn.DNN(net)
model.fit(data, labels, n_epoch=10, batch_size=16, show_metric=True)
这给了我一对夫妇的错误,首先是...
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 1 but is rank 2 for 'strided_slice' (op: 'StridedSlice') with input shapes: [6605,1], [1,16], [1,16], [1].
...第二个是...
During handling of the above exception, another exception occurred:
ValueError: Shape must be rank 1 but is rank 2 for 'strided_slice' (op: 'StridedSlice') with input shapes: [6605,1], [1,16], [1,16], [1].
我不知道什么rank 1
和rank 2
是,所以我不知道如何解决这个问题。
尝试删除“标签”的整形;错误是否持续?它是提供一个你的数据样本(也可以是任何提供此模型的链接,如你所说,将是有用的) – desertnaut