Browse Source

update example

master
Joerg Marks 2 years ago
parent
commit
faf8a846d3
  1. 34
      notebooks/03_ml_basics_display_HorseOrHuman.ipynb

34
notebooks/03_ml_basics_display_HorseOrHuman.ipynb

@ -104,7 +104,9 @@
"source": [ "source": [
"# Get the number of elements in the training and validation dataset\n", "# Get the number of elements in the training and validation dataset\n",
"train_size = tf.data.experimental.cardinality(train_dataset).numpy()\n", "train_size = tf.data.experimental.cardinality(train_dataset).numpy()\n",
"valid_size = tf.data.experimental.cardinality(valid_dataset).numpy()"
"valid_size = tf.data.experimental.cardinality(valid_dataset).numpy()\n",
"print(\"Training dataset size:\", train_size)\n",
"print(\"Validation dataset size:\", valid_size)"
] ]
}, },
{ {
@ -139,24 +141,10 @@
"valid_dataset = valid_dataset.map(preprocess)\n", "valid_dataset = valid_dataset.map(preprocess)\n",
"\n", "\n",
"# Batch and shuffle the datasets\n", "# Batch and shuffle the datasets\n",
"train_dataset = train_dataset.shuffle(2000).batch(80)\n",
"train_dataset = train_dataset.shuffle(1000).batch(80)\n",
"valid_dataset = valid_dataset.batch(20)" "valid_dataset = valid_dataset.batch(20)"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "9399bc99",
"metadata": {},
"outputs": [],
"source": [
"# Get the number of elements in the trainingand validation dataset\n",
"train_size = tf.data.experimental.cardinality(train_dataset).numpy()\n",
"valid_size = tf.data.experimental.cardinality(valid_dataset).numpy()\n",
"print(\"Training dataset size:\", train_size)\n",
"print(\"Validation dataset size:\", valid_size)"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@ -171,13 +159,21 @@
" \n", " \n",
"print(x_val.shape, y_val.shape)" "print(x_val.shape, y_val.shape)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"id": "67e152ff-0713-4629-8471-1afbb1bf22a6",
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python [conda env:ML]",
"language": "python", "language": "python",
"name": "python3"
"name": "conda-env-ML-py"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": {
@ -189,7 +185,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.10.9"
} }
}, },
"nbformat": 4, "nbformat": 4,

Loading…
Cancel
Save