model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dense(10) # softmax 는 numerical stability 보장 안됨:
# softmax 안쓴다는 것은 logit 개념으로 softmax 들어가기 전에 값을 가지고 와서 사용 한다는 의미,
# 논리니어티가 아니라 readout
# tf.nn.sigmoid_cross_entropy_with_logits 사용하면 numerical stability 보장 되기 때문에
])
Model: "model"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) [(None, 28, 28)] 0
flatten (Flatten) (None, 784) 0
dense (Dense) (None, 128) 100480
dense_1 (Dense) (None, 10) 1290
=================================================================
Total params: 101,770
Trainable params: 101,770
Non-trainable params: 0
_________________________________________________________________
1875/1875 [==============================] - 14s 6ms/step - loss: 496111.7812
<keras.callbacks.History at 0x1cd09de8850>
1875/1875 [==============================] - 11s 6ms/step - loss: 2.7764
<keras.callbacks.History at 0x1cd17ed9d60>
1875/1875 [==============================] - 11s 6ms/step - loss: 2.6502
<keras.callbacks.History at 0x1cc97e62730>
1875/1875 [==============================] - 12s 6ms/step - loss: 733138.9375
<keras.callbacks.History at 0x1cc97f27910>
Epoch 1/5
1875/1875 [==============================] - 12s 6ms/step - loss: 3.8974
Epoch 2/5
1875/1875 [==============================] - 11s 6ms/step - loss: 2.3095
Epoch 3/5
1875/1875 [==============================] - 11s 6ms/step - loss: 2.3037
Epoch 4/5
1875/1875 [==============================] - 11s 6ms/step - loss: 2.3026
Epoch 5/5
1875/1875 [==============================] - 12s 6ms/step - loss: 2.3026
<keras.callbacks.History at 0x1cd11c5cdc0>
Epoch 1/5
1875/1875 [==============================] - 12s 6ms/step - loss: 3.0797
Epoch 2/5
1875/1875 [==============================] - 11s 6ms/step - loss: 0.5858
Epoch 3/5
1875/1875 [==============================] - 11s 6ms/step - loss: 0.4708
Epoch 4/5
1875/1875 [==============================] - 10s 5ms/step - loss: 0.4371
Epoch 5/5
1875/1875 [==============================] - 10s 5ms/step - loss: 0.3952
<keras.callbacks.History at 0x1cd225b9c70>
Epoch 1/5
1875/1875 [==============================] - 12s 6ms/step - loss: 0.2545
Epoch 2/5
1875/1875 [==============================] - 11s 6ms/step - loss: 0.1194
Epoch 3/5
1875/1875 [==============================] - 10s 5ms/step - loss: 0.0877
Epoch 4/5
1875/1875 [==============================] - 9s 5ms/step - loss: 0.0717
Epoch 5/5
1875/1875 [==============================] - 9s 5ms/step - loss: 0.0611
<keras.callbacks.History at 0x1cd263b7cd0>