training with result, sorta+

master
ml server 2020-01-15 15:32:28 -07:00
parent 6a6c008fbb
commit 8929e7182f
1 changed files with 187 additions and 101 deletions

View File

@ -626,27 +626,52 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 319,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"TRAINING info\n"
]
}
],
"source": [
"print(\"TRAINING\")"
"print(\"TRAINING info\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 320,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data/train\n"
]
}
],
"source": [
"print(train_dir)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 321,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data/train/good\n",
"data/train/bad\n"
]
}
],
"source": [
"print(train_good_dir)\n",
"print(train_bad_dir)"
@ -654,43 +679,67 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 322,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<tensorflow.python.keras.preprocessing.image.ImageDataGenerator object at 0x7f0864059e80>\n"
]
}
],
"source": [
"print(train_image_generator)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 323,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<keras_preprocessing.image.directory_iterator.DirectoryIterator object at 0x7f084076d048>\n"
]
}
],
"source": [
"print(train_data_gen)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 332,
"metadata": {},
"outputs": [],
"source": [
"print(sample_train_images)"
"#print(sample_train_images)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 325,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<tensorflow.python.keras.callbacks.History object at 0x7f08642b4390>\n"
]
}
],
"source": [
"print(history)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 334,
"metadata": {},
"outputs": [],
"source": [
@ -721,9 +770,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 327,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"predict\n"
]
}
],
"source": [
"# https://keras.io/models/sequential/\n",
"print(\"predict\")"
@ -731,9 +788,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 328,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4/4 [==============================] - 1s 220ms/step\n"
]
}
],
"source": [
"pred=model.predict_generator(test_data_gen,\n",
"steps=4,\n",
@ -742,9 +807,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 335,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1/1 - 0s\n",
"end predict\n"
]
}
],
"source": [
"prediction = model.predict(\n",
" x=test_data_gen,\n",
@ -762,7 +836,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 336,
"metadata": {},
"outputs": [],
"source": [
@ -771,9 +845,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 337,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[0.9941876]]\n"
]
}
],
"source": [
"# Show prediction score\n",
"print(prediction)"
@ -781,23 +863,98 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 338,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[False]]\n"
]
}
],
"source": [
"#prediction_bool = (prediction >0.5)\n",
"prediction_bool = (prediction == 1)\n",
"print(prediction_bool)"
]
},
{
"cell_type": "code",
"execution_count": 339,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[0]]\n"
]
}
],
"source": [
"predictions = prediction_bool.astype(int)\n",
"print(predictions)"
]
},
{
"cell_type": "code",
"execution_count": 345,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Observation: bad\n"
]
}
],
"source": [
"# Make final prediction\n",
"if prediction_bool == False:\n",
" rating = 'bad'\n",
"else:\n",
" rating = 'good'\n",
"print('Observation: %s' % (rating))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"predictions = prediction_bool.astype(int)\n",
"print(predictions)"
"barf()"
]
},
{
@ -899,69 +1056,6 @@
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
@ -1091,15 +1185,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Make final prediction\n",
"#if prediction[0][0] == 0:\n",
"if prediction == [[0]]:\n",
" rating = 'bad'\n",
"else:\n",
" rating = 'good'\n",
"print('Observation: %s' % (rating))"
]
"source": []
},
{
"cell_type": "code",