From a98e4a659e1425376718a471ee5d91be63ab3a5f Mon Sep 17 00:00:00 2001 From: Shorna Alam Date: Sun, 7 Jan 2024 19:18:54 -0500 Subject: [PATCH] added alterations to lab1 solutions (part1 and part2) --- lab1/solutions/Part1_TensorFlow_Solution.ipynb | 2 +- .../Part2_Music_Generation_Solution.ipynb | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lab1/solutions/Part1_TensorFlow_Solution.ipynb b/lab1/solutions/Part1_TensorFlow_Solution.ipynb index 610889fd..fd75bb64 100644 --- a/lab1/solutions/Part1_TensorFlow_Solution.ipynb +++ b/lab1/solutions/Part1_TensorFlow_Solution.ipynb @@ -95,7 +95,7 @@ "source": [ "%pip install comet_ml\n", "import comet_ml\n", - "comet_ml.init(project_name=\"6.s191lab1.1.0\")\n", + "comet_ml.init(project_name=\"6.s191lab1_part0\")\n", "comet_experiment = comet_ml.Experiment()" ] }, diff --git a/lab1/solutions/Part2_Music_Generation_Solution.ipynb b/lab1/solutions/Part2_Music_Generation_Solution.ipynb index 531be2cd..229843c8 100644 --- a/lab1/solutions/Part2_Music_Generation_Solution.ipynb +++ b/lab1/solutions/Part2_Music_Generation_Solution.ipynb @@ -195,7 +195,7 @@ "source": [ "%pip install comet_ml\n", "import comet_ml\n", - "comet_ml.init(project_name=\"6.s191lab1.2\")\n", + "comet_ml.init(project_name=\"6.s191lab1_part2\")\n", "comet_experiment = comet_ml.Experiment()\n", "\n", "# Import Tensorflow 2.0\n", @@ -219,7 +219,9 @@ "\n", "# Check that we are using a GPU, if not switch runtimes\n", "# using Runtime > Change Runtime Type > GPU\n", - "assert len(tf.config.list_physical_devices('GPU')) > 0" + "assert len(tf.config.list_physical_devices('GPU')) > 0\n", + "\n", + "from scipy.io.wavfile import write" ] }, { @@ -1099,8 +1101,7 @@ " model.save_weights(checkpoint_prefix)\n", " \n", "# Save the trained model and the weights\n", - "model.save_weights(checkpoint_prefix)\n", - "comet_experiment.end()\n" + "model.save_weights(checkpoint_prefix)\n" ] }, { @@ -1275,7 +1276,14 @@ " # If its a valid song (correct syntax), lets play it! \n", " if waveform:\n", " print(\"Generated song\", i)\n", - " ipythondisplay.display(waveform)" + " ipythondisplay.display(waveform)\n", + "\n", + " numeric_data = np.frombuffer(waveform.data, dtype=np.int16)\n", + " wav_file_path = f\"output_{i}.wav\"\n", + " write(wav_file_path, 88200, numeric_data)\n", + " comet_experiment.log_asset(wav_file_path)\n", + " \n", + "comet_experiment.end()" ] }, {