我正在使用由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