简体   繁体   English

Tensorflow:试图让玩具神经网络``学习''

[英]Tensorflow: trying to get toy neural network to 'learn'

Trying to get very simple ('toy') 2-layer neural network to build model, as a learning example to make sure the math flows correctly. 尝试获取非常简单的(“玩具”)2层神经网络来构建模型,作为确保数学正确流动的学习示例。

The model should learn that a '1' on the first and last feature equates to a '1' output. 该模型应了解到,第一个和最后一个特征上的“ 1”等于“ 1”输出。

features = []
features.append([[0, 0, 0, 0, 0], [0]])
features.append([[0, 0, 0, 0, 1], [0]])
features.append([[0, 0, 0, 1, 1], [0]])
features.append([[0, 0, 1, 1, 1], [0]])
features.append([[0, 1, 1, 1, 1], [0]])
features.append([[1, 1, 1, 1, 0], [0]])
features.append([[1, 1, 1, 0, 0], [0]])
features.append([[1, 1, 0, 0, 0], [0]])
features.append([[1, 0, 0, 0, 0], [0]])
features.append([[1, 0, 0, 1, 0], [0]])
features.append([[1, 0, 1, 1, 0], [0]])
features.append([[1, 1, 0, 1, 0], [0]])
features.append([[0, 1, 0, 1, 1], [0]])
features.append([[0, 0, 1, 0, 1], [0]])
# output of [1] of positions [0,4]==1
features.append([[1, 0, 0, 0, 1], [1]])
features.append([[1, 1, 0, 0, 1], [1]])
features.append([[1, 1, 1, 0, 1], [1]])
features.append([[1, 1, 1, 1, 1], [1]])
features.append([[1, 0, 0, 1, 1], [1]])
features.append([[1, 0, 1, 1, 1], [1]])
features.append([[1, 1, 0, 1, 1], [1]])
features.append([[1, 0, 1, 0, 1], [1]])

However I cannot get any error/cost to show up... 但是我无法显示任何错误/费用...

Epoch 3 completed out of 10 cost: 0.0
Epoch 5 completed out of 10 cost: 0.0
Epoch 7 completed out of 10 cost: 0.0
Epoch 9 completed out of 10 cost: 0.0
Accuracy: 1.0

Thanks in advance for having a quick look: here is the notebook ... 在此先感谢您快速浏览: 这是笔记本电脑 ...

The problem turned out to be the output, it needed to be a 2-class array. 问题出在输出,它必须是2类数组。 Not sure why this is necessarily the case. 不知道为什么一定要这样。

features.append([[0, 0, 0, 0, 0], [0,1]])
features.append([[0, 0, 0, 0, 1], [0,1]])
features.append([[0, 0, 0, 1, 1], [0,1]])
features.append([[0, 0, 1, 1, 1], [0,1]])
features.append([[0, 1, 1, 1, 1], [0,1]])

the working notebook is here . 工作的笔记本在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM