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