Wykład 11 - sieci neuronowe w praktyce - poprawki
This commit is contained in:
parent
f531933b38
commit
8c67bcbc33
@ -858,7 +858,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 52,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"slideshow": {
|
"slideshow": {
|
||||||
"slide_type": "subslide"
|
"slide_type": "subslide"
|
||||||
@ -878,7 +878,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 53,
|
"execution_count": 2,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"slideshow": {
|
"slideshow": {
|
||||||
"slide_type": "notes"
|
"slide_type": "notes"
|
||||||
@ -901,7 +901,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 54,
|
"execution_count": 3,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"slideshow": {
|
"slideshow": {
|
||||||
"slide_type": "subslide"
|
"slide_type": "subslide"
|
||||||
@ -934,7 +934,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 55,
|
"execution_count": 4,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"slideshow": {
|
"slideshow": {
|
||||||
"slide_type": "subslide"
|
"slide_type": "subslide"
|
||||||
@ -969,7 +969,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 56,
|
"execution_count": 9,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"scrolled": true,
|
"scrolled": true,
|
||||||
"slideshow": {
|
"slideshow": {
|
||||||
@ -981,19 +981,19 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Model: \"sequential_21\"\n",
|
"Model: \"sequential_1\"\n",
|
||||||
"_________________________________________________________________\n",
|
"_________________________________________________________________\n",
|
||||||
"Layer (type) Output Shape Param # \n",
|
"Layer (type) Output Shape Param # \n",
|
||||||
"=================================================================\n",
|
"=================================================================\n",
|
||||||
"dense_59 (Dense) (None, 512) 401920 \n",
|
"dense_3 (Dense) (None, 512) 401920 \n",
|
||||||
"_________________________________________________________________\n",
|
"_________________________________________________________________\n",
|
||||||
"dropout_2 (Dropout) (None, 512) 0 \n",
|
"dropout (Dropout) (None, 512) 0 \n",
|
||||||
"_________________________________________________________________\n",
|
"_________________________________________________________________\n",
|
||||||
"dense_60 (Dense) (None, 512) 262656 \n",
|
"dense_4 (Dense) (None, 512) 262656 \n",
|
||||||
"_________________________________________________________________\n",
|
"_________________________________________________________________\n",
|
||||||
"dropout_3 (Dropout) (None, 512) 0 \n",
|
"dropout_1 (Dropout) (None, 512) 0 \n",
|
||||||
"_________________________________________________________________\n",
|
"_________________________________________________________________\n",
|
||||||
"dense_61 (Dense) (None, 10) 5130 \n",
|
"dense_5 (Dense) (None, 10) 5130 \n",
|
||||||
"=================================================================\n",
|
"=================================================================\n",
|
||||||
"Total params: 669,706\n",
|
"Total params: 669,706\n",
|
||||||
"Trainable params: 669,706\n",
|
"Trainable params: 669,706\n",
|
||||||
@ -1009,12 +1009,13 @@
|
|||||||
"model.add(Dense(512, activation='relu'))\n",
|
"model.add(Dense(512, activation='relu'))\n",
|
||||||
"model.add(Dropout(0.2))\n",
|
"model.add(Dropout(0.2))\n",
|
||||||
"model.add(Dense(num_classes, activation='softmax'))\n",
|
"model.add(Dense(num_classes, activation='softmax'))\n",
|
||||||
"model.summary()"
|
"\n",
|
||||||
|
"model.summary() # wyświetl podsumowanie architektury sieci"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 57,
|
"execution_count": 10,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"slideshow": {
|
"slideshow": {
|
||||||
"slide_type": "subslide"
|
"slide_type": "subslide"
|
||||||
@ -1035,7 +1036,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 58,
|
"execution_count": 12,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"slideshow": {
|
"slideshow": {
|
||||||
"slide_type": "subslide"
|
"slide_type": "subslide"
|
||||||
@ -1046,25 +1047,35 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Epoch 1/5\n",
|
"Epoch 1/10\n",
|
||||||
"469/469 [==============================] - 11s 23ms/step - loss: 0.2463 - accuracy: 0.9238 - val_loss: 0.1009 - val_accuracy: 0.9690\n",
|
"469/469 [==============================] - 20s 42ms/step - loss: 0.0957 - accuracy: 0.9708 - val_loss: 0.0824 - val_accuracy: 0.9758\n",
|
||||||
"Epoch 2/5\n",
|
"Epoch 2/10\n",
|
||||||
"469/469 [==============================] - 10s 22ms/step - loss: 0.1042 - accuracy: 0.9681 - val_loss: 0.0910 - val_accuracy: 0.9739\n",
|
"469/469 [==============================] - 20s 43ms/step - loss: 0.0693 - accuracy: 0.9793 - val_loss: 0.0807 - val_accuracy: 0.9772\n",
|
||||||
"Epoch 3/5\n",
|
"Epoch 3/10\n",
|
||||||
"469/469 [==============================] - 11s 23ms/step - loss: 0.0774 - accuracy: 0.9762 - val_loss: 0.0843 - val_accuracy: 0.9755\n",
|
"469/469 [==============================] - 18s 38ms/step - loss: 0.0563 - accuracy: 0.9827 - val_loss: 0.0861 - val_accuracy: 0.9758\n",
|
||||||
"Epoch 4/5\n",
|
"Epoch 4/10\n",
|
||||||
"469/469 [==============================] - 11s 24ms/step - loss: 0.0606 - accuracy: 0.9815 - val_loss: 0.0691 - val_accuracy: 0.9818\n",
|
"469/469 [==============================] - 18s 37ms/step - loss: 0.0485 - accuracy: 0.9857 - val_loss: 0.0829 - val_accuracy: 0.9794\n",
|
||||||
"Epoch 5/5\n",
|
"Epoch 5/10\n",
|
||||||
"469/469 [==============================] - 10s 22ms/step - loss: 0.0504 - accuracy: 0.9848 - val_loss: 0.0886 - val_accuracy: 0.9772\n"
|
"469/469 [==============================] - 19s 41ms/step - loss: 0.0428 - accuracy: 0.9876 - val_loss: 0.0955 - val_accuracy: 0.9766\n",
|
||||||
|
"Epoch 6/10\n",
|
||||||
|
"469/469 [==============================] - 22s 47ms/step - loss: 0.0377 - accuracy: 0.9887 - val_loss: 0.0809 - val_accuracy: 0.9794\n",
|
||||||
|
"Epoch 7/10\n",
|
||||||
|
"469/469 [==============================] - 17s 35ms/step - loss: 0.0338 - accuracy: 0.9904 - val_loss: 0.1028 - val_accuracy: 0.9788\n",
|
||||||
|
"Epoch 8/10\n",
|
||||||
|
"469/469 [==============================] - 17s 36ms/step - loss: 0.0322 - accuracy: 0.9911 - val_loss: 0.0937 - val_accuracy: 0.9815\n",
|
||||||
|
"Epoch 9/10\n",
|
||||||
|
"469/469 [==============================] - 18s 37ms/step - loss: 0.0303 - accuracy: 0.9912 - val_loss: 0.0916 - val_accuracy: 0.9829.0304 - accu\n",
|
||||||
|
"Epoch 10/10\n",
|
||||||
|
"469/469 [==============================] - 16s 34ms/step - loss: 0.0263 - accuracy: 0.9926 - val_loss: 0.0958 - val_accuracy: 0.9812\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<tensorflow.python.keras.callbacks.History at 0x1ed6e0565b0>"
|
"<tensorflow.python.keras.callbacks.History at 0x228eac95ac0>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 58,
|
"execution_count": 12,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@ -1072,13 +1083,13 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"model.compile(loss='categorical_crossentropy', optimizer=keras.optimizers.RMSprop(), metrics=['accuracy'])\n",
|
"model.compile(loss='categorical_crossentropy', optimizer=keras.optimizers.RMSprop(), metrics=['accuracy'])\n",
|
||||||
"\n",
|
"\n",
|
||||||
"model.fit(x_train, y_train, batch_size=128, epochs=5, verbose=1,\n",
|
"model.fit(x_train, y_train, batch_size=128, epochs=10, verbose=1,\n",
|
||||||
" validation_data=(x_test, y_test))"
|
" validation_data=(x_test, y_test))"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 60,
|
"execution_count": 8,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"slideshow": {
|
"slideshow": {
|
||||||
"slide_type": "subslide"
|
"slide_type": "subslide"
|
||||||
@ -1089,8 +1100,8 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Test loss: 0.08859136700630188\n",
|
"Test loss: 0.0757974311709404\n",
|
||||||
"Test accuracy: 0.9771999716758728\n"
|
"Test accuracy: 0.9810000061988831\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -1109,7 +1120,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"Warstwa _dropout_ to metoda regularyzacji, służy zapobieganiu nadmiernemu dopasowaniu sieci. Polega na tym, że część węzłów sieci jest usuwana w sposób losowy."
|
"Warstwa *dropout* to metoda regularyzacji, służy zapobieganiu nadmiernemu dopasowaniu sieci. Polega na tym, że część węzłów sieci jest usuwana w sposób losowy."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1884,7 +1895,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.8.5"
|
"version": "3.8.3"
|
||||||
},
|
},
|
||||||
"livereveal": {
|
"livereveal": {
|
||||||
"start_slideshow_at": "selected",
|
"start_slideshow_at": "selected",
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user