DeepLearning_Lab09_02 - 8BitsCoding/RobotMentor GitHub Wiki


이미지

# Lab 9 XOR
import tensorflow as tf
import numpy as np

tf.set_random_seed(777)  # for reproducibility

x_data = np.array([0, 0], [0, 1], [1, 0], [1, 1](/8BitsCoding/RobotMentor/wiki/0,-0],-[0,-1],-[1,-0],-[1,-1), dtype=np.float32)
y_data = np.array([0], [1], [1], [0](/8BitsCoding/RobotMentor/wiki/0],-[1],-[1],-[0), dtype=np.float32)

X = tf.placeholder(tf.float32, [None, 2])
Y = tf.placeholder(tf.float32, [None, 1])
W1 = tf.Variable(tf.random_normal([2, 10]), name='weight1')
b1 = tf.Variable(tf.random_normal([10]), name='bias1')
layer1 = tf.sigmoid(tf.matmul(X, W1) + b1)

W2 = tf.Variable(tf.random_normal([10, 10]), name='weight2')
b2 = tf.Variable(tf.random_normal([10]), name='bias2')
layer2 = tf.sigmoid(tf.matmul(layer1, W2) + b2)

W3 = tf.Variable(tf.random_normal([10, 10]), name='weight3')
b3 = tf.Variable(tf.random_normal([10]), name='bias3')
layer3 = tf.sigmoid(tf.matmul(layer2, W3) + b3)

W4 = tf.Variable(tf.random_normal([10, 1]), name='weight4')
b4 = tf.Variable(tf.random_normal([1]), name='bias4')
hypothesis = tf.sigmoid(tf.matmul(layer3, W4) + b4)

깊고 λ„“κ²Œ ν•™μŠ΅ μ‹œ λ”μš± μ •ν™•ν•œ 데이터가 λ‚˜μ˜¨λ‹€.