Giter Site home page Giter Site logo

Comments (1)

matthewdrees avatar matthewdrees commented on September 13, 2024

This fixed it for me. Give me (limited) permission and I can create a PR.

Author: Matt Drees <[email protected]>  2022-06-06 12:21:58
Committer: Matt Drees <[email protected]>  2022-06-06 12:21:58
Parent: 060eb9f9be1d7f7e2d7e103a29a01386723c22fe (Merge pull request #28 from robertlacok/patch-1)
Child:  0000000000000000000000000000000000000000 (Local uncommitted changes, not checked in to index)
Branch: fix_two_phase_predictions_ipynb
Follows: 
Precedes: 

    Fixes for two_phase_predictions.ipynb.
    
    Fixes:
    * "audio" -> "audio_spectros" path
    * "image_batch" variable not found.
    * fit_generator() method deprecated, prefer fit().
    * Moved the *.png files so redownload them.
    
    Tested by re-running the notebook from scratch.

------------------ 05_resilience/two_phase_predictions.ipynb ------------------
index dbd3383..fb3243d 100644
@@ -701,7 +701,7 @@
    },
    "outputs": [],
    "source": [
-    "data_dir = pathlib.Path(os.getcwd() + '/audio')\n",
+    "data_dir = pathlib.Path(os.getcwd() + '/audio_spectros')\n",
     "class_names = ['not_instrument', 'instrument']"
    ]
   },
@@ -897,7 +897,7 @@
    },
    "outputs": [],
    "source": [
-    "feature_batch = mobilenet(image_batch)"
+    "feature_batch = mobilenet(val_image)"
    ]
   },
   {
@@ -1045,9 +1045,9 @@
    },
    "outputs": [],
    "source": [
-    "model.fit_generator(train_data_gen, \n",
-    "                    validation_data=val_data_gen,\n",
-    "                    steps_per_epoch=STEPS_PER_EPOCH, epochs=10)"
+    "model.fit(train_data_gen,\n",
+    "          validation_data=val_data_gen,\n",
+    "          steps_per_epoch=STEPS_PER_EPOCH, epochs=10)"
    ]
   },
   {
@@ -1366,6 +1366,24 @@
     "Create directories for each instrument label. We'll use this later when we load our images with Keras's `ImageDataGenerator` class."
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {
+    "colab": {
+     "base_uri": "https://localhost:8080/",
+     "height": 1000
+    },
+    "colab_type": "code",
+    "id": "IsipOIHWaFQW",
+    "outputId": "76542e83-ec27-4dfd-c3f9-d3402faf99e2"
+   },
+   "outputs": [],
+   "source": [
+    "# Moved them so have to download them again.\n",
+    "!gsutil -m cp -r gs://ml-design-patterns/audio_train_spectro ."
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": 299,
@@ -1512,7 +1530,7 @@
     }
    ],
    "source": [
-    "feature_batch = vgg_model(image_batch)\n",
+    "feature_batch = vgg_model(image_instrument_train)\n",
     "global_avg_layer = tf.keras.layers.GlobalAveragePooling2D()\n",
     "feature_batch_avg = global_avg_layer(feature_batch)\n",
     "print(feature_batch_avg.shape)"
@@ -1604,7 +1622,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "instrument_model.fit_generator(\n",
+    "instrument_model.fit(\n",
     "    train_data_instrument, \n",
     "    validation_data=val_data_instrument,\n",
     "    steps_per_epoch=STEPS_PER_EPOCH, epochs=10)"
@@ -1694,4 +1712,4 @@
  },
  "nbformat": 4,
  "nbformat_minor": 4
-}
\ No newline at end of file
+}

from ml-design-patterns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.