小编rde*_*com的帖子

tflearn/tensorflow不学习xor

编写以下代码以学习XOR功能,但是大约一半的时间网络没有学习并且每个时期之后的损失保持不变.

train_f = [[0, 0], [0, 1], [1, 0], [1, 1]]
train_c = [[0], [1], [1], [0]]
test_f = train_f
test_c = train_c

import tensorflow as tf
import tflearn

X = [[0., 0.], [0., 1.], [1., 0.], [1., 1.]]
Y_xor = [[0.], [1.], [1.], [0.]]

# Graph definition
with tf.Graph().as_default():
    # Building a network with 2 optimizers
    net = tflearn.input_data(shape=[None, 2])
    # Nand operator definition
    net = tflearn.fully_connected(net, 2, activation='relu')
    net = tflearn.fully_connected(net, 2, activation='relu')
    net = tflearn.fully_connected(net, 1, activation='sigmoid') …
Run Code Online (Sandbox Code Playgroud)

python machine-learning deep-learning tensorflow

8
推荐指数
2
解决办法
1610
查看次数