<jupyter_start><jupyter_text><jupyter_code>import tensorflow as tf
x_data = [[0,0], [1,0], [0,1], [1,1]]
y_data = [[0],[1],[1],[1]]
type(x_data), type(y_data)
import numpy as np
x_train = np.array(x_data)
y_train = np.array(y_data)
x_train.shape, y_train.shape<jupyter_output><empty_output><jupyter_text>create model<jupyter_code>model = tf.keras.models.Sequential()

# solve XOR model
model.add(tf.keras.Input(shape=(2,)))  # input layer
model.add(tf.keras.layers.Dense(128, activation='sigmoid')) # 기능 layer
model.add(tf.keras.layers.Dense(128, activation='sigmoid')) # 기능 layer
model.add(tf.keras.layers.Dense(1, activation='sigmoid')) # output layer

model.compile(optimizer='sgd', loss='mse', metrics=['acc'])
tf.keras.utils.plot_model(model, show_shapes=True)
model.fit(x_train, y_train, epochs=100)
#model.predict([[0,1]])  # dense : 2, epoch : 100, loss: 0.2021
#model.predict([[0,1]])  # dense : 32, epoch : 100, loss: 0.1943 > 0.6372154
model.predict([[0,1]])  # dense : 128, epoch : 100, loss: 0.2021 > 0.7239666
model.predict([[0,1]])  # dense : 128*2, loss: 0.1856 
model.evaluate(x_train, y_train)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19456617002629273, 'fraction_numerical': 0.07537248028045573, 'mean_word_length': 6.613333333333333, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '268236', 'license': 'Apache-2.0', 'n_tokens_mistral': 527, 'n_tokens_neox': 481, 'n_words': 81, 'path': 'multi_perceptron.ipynb', 'repo_name': 'fonslucens/test_deeplearning', 'size': '1141'}