0
我是新來的機器學習和Tensorflow,並希望做一個簡單的二維分類與數據,不能線性分離。張量流的非線性分類
在左側,您可以看到模型的訓練數據。 右側顯示訓練模型預測的內容。
截至目前,我過度配合我的模型,所以每一個可能的輸入都被輸入到模型中。 我的預期結果將是非常高的準確性,因爲模型已經「知道」每個答案。 不幸的是,我所使用的深度神經網絡只能通過線性分頻器進行分離,這不符合我的數據。
這是我訓練我的型號:
def testDNN(data):
"""
* data is a list of tuples (x, y, b),
* where (x, y) is the input vector and b is the expected output
"""
# Build neural network
net = tflearn.input_data(shape=[None, 2])
net = tflearn.fully_connected(net, 100)
net = tflearn.fully_connected(net, 100)
net = tflearn.fully_connected(net, 100)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net)
# Define model
model = tflearn.DNN(net)
# check if we already have a trained model
# Start training (apply gradient descent algorithm)
model.fit(
[(x,y) for (x,y,b) in data],
[([1, 0] if b else [0, 1]) for (x,y,b) in data],
n_epoch=2, show_metric=True)
return lambda x,y: model.predict([[x, y]])[0][0]
大部分是從tflearn的例子取,所以我完全不明白,每一行做什麼。
試試增加n_epoch? – frankyjuang
增加n_epoch並不會改變精度,大約是50%。像硬幣翻轉會。 – RincewindWizzard
不確定這是否是一個特定的模型選擇,您不希望在您的初始三個線性圖層之後出現非線性,或者默認情況下tf-learn放置(我對tf-learn知之甚少),但應具有非線性幫幫我。 – Akash