반응형
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, _), (x_test, _) = mnist.load_data()
x_train, x_test = x_train/255.0, x_test/255.0
x_train = x_test.reshape((10000, 784))
x_test = x_test.reshape((10000,784))
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=(784, )),
tf.keras.layers.Dense(256, activation='relu'),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dense(784, activation='sigmoid'),
])
model.compile(optimizer='adam', loss=('mse'))
model.fit(x_train, x_train, epochs=1)
p_test = model.predict(x_test)
import matplotlib.pyplot as plt
x_test = x_test.reshape(10000, 28, 28)
p_test = p_test.reshape(10000, 28, 28)
plt.figure()
plt.imshow(x_test[0])
plt.show()
plt.figure()
plt.imshow(p_test[0])
plt.show()
plt.figure(figsize=(10, 10))
for i in range(100):
plt.subplot(10, 10, i+1)
plt.xticks([])
plt.yticks([])
plt.imshow(x_test[i])
plt.show()
반응형
'Deep Learning' 카테고리의 다른 글
ScikitLearn_MLBasic.02 (0) | 2022.09.16 |
---|---|
Machine Learning_MLBasic.01 (0) | 2022.09.16 |
YOLO (0) | 2022.09.14 |
Library_Pandas_2 (0) | 2022.09.14 |
Library_Pandas_1 (0) | 2022.09.14 |