|
61 | 61 | },
|
62 | 62 | "outputs": [],
|
63 | 63 | "source": [
|
64 |
| - "#Import Comet\n", |
65 |
| - "%pip install comet_ml\n", |
66 |
| - "import comet_ml\n", |
67 |
| - "comet_ml.init(project_name=\"6.s191lab2.1.1\")\n", |
68 |
| - "comet_model_1 = comet_ml.Experiment()\n", |
69 |
| - "\n", |
70 | 64 | "# Import Tensorflow 2.0\n",
|
71 | 65 | "%tensorflow_version 2.x\n",
|
72 | 66 | "import tensorflow as tf \n",
|
73 | 67 | "\n",
|
74 | 68 | "!pip install mitdeeplearning\n",
|
75 | 69 | "import mitdeeplearning as mdl\n",
|
76 | 70 | "\n",
|
| 71 | + "#Import Comet\n", |
| 72 | + "!pip install comet_ml\n", |
| 73 | + "import comet_ml\n", |
| 74 | + "comet_ml.init(project_name=\"6.s191lab2_part1_NN\")\n", |
| 75 | + "comet_model_1 = comet_ml.Experiment()\n", |
| 76 | + "\n", |
77 | 77 | "import matplotlib.pyplot as plt\n",
|
78 | 78 | "import numpy as np\n",
|
79 | 79 | "import random\n",
|
80 |
| - "from tqdm import tqdm\n", |
81 |
| - "\n", |
82 |
| - "# Check that we are using a GPU, if not switch runtimes\n", |
83 |
| - "# using Runtime > Change Runtime Type > GPU\n", |
84 |
| - "assert len(tf.config.list_physical_devices('GPU')) > 0" |
| 80 | + "from tqdm import tqdm" |
85 | 81 | ]
|
86 | 82 | },
|
87 | 83 | {
|
|
421 | 417 | },
|
422 | 418 | "outputs": [],
|
423 | 419 | "source": [
|
424 |
| - "comet_ml.init(project_name=\"6.s191lab2.1.2\")\n", |
| 420 | + "comet_ml.init(project_name=\"6.s191lab2_part1_CNN\")\n", |
425 | 421 | "comet_model_2 = comet_ml.Experiment()\n",
|
426 | 422 | "\n",
|
427 | 423 | "'''TODO: Define the compile operation with your optimizer and learning rate of choice'''\n",
|
|
568 | 564 | "outputs": [],
|
569 | 565 | "source": [
|
570 | 566 | "print(\"Label of this digit is:\", test_labels[0])\n",
|
571 |
| - "plt.imshow(test_images[0,:,:,0], cmap=plt.cm.binary)" |
| 567 | + "plt.imshow(test_images[0,:,:,0], cmap=plt.cm.binary)\n", |
| 568 | + "comet_model_2.log_figure(figure=plt)" |
572 | 569 | ]
|
573 | 570 | },
|
574 | 571 | {
|
|
594 | 591 | "plt.subplot(1,2,1)\n",
|
595 | 592 | "mdl.lab2.plot_image_prediction(image_index, predictions, test_labels, test_images)\n",
|
596 | 593 | "plt.subplot(1,2,2)\n",
|
597 |
| - "mdl.lab2.plot_value_prediction(image_index, predictions, test_labels)" |
| 594 | + "mdl.lab2.plot_value_prediction(image_index, predictions, test_labels)\n", |
| 595 | + "comet_model_2.log_figure(figure=plt)" |
598 | 596 | ]
|
599 | 597 | },
|
600 | 598 | {
|
|
624 | 622 | " plt.subplot(num_rows, 2*num_cols, 2*i+1)\n",
|
625 | 623 | " mdl.lab2.plot_image_prediction(i, predictions, test_labels, test_images)\n",
|
626 | 624 | " plt.subplot(num_rows, 2*num_cols, 2*i+2)\n",
|
627 |
| - " mdl.lab2.plot_value_prediction(i, predictions, test_labels)\n" |
| 625 | + " mdl.lab2.plot_value_prediction(i, predictions, test_labels)\n", |
| 626 | + "comet_model_2.log_figure(figure=plt)\n", |
| 627 | + "comet_model_2.end()" |
628 | 628 | ]
|
629 | 629 | },
|
630 | 630 | {
|
|
658 | 658 | "plotter = mdl.util.PeriodicPlotter(sec=2, xlabel='Iterations', ylabel='Loss', scale='semilogy')\n",
|
659 | 659 | "optimizer = tf.keras.optimizers.SGD(learning_rate=1e-2) # define our optimizer\n",
|
660 | 660 | "\n",
|
661 |
| - "comet_ml.init(project_name=\"6.s191lab2.1.3\")\n", |
| 661 | + "comet_ml.init(project_name=\"6.s191lab2_part1_CNN2\")\n", |
662 | 662 | "comet_model_3 = comet_ml.Experiment()\n",
|
663 | 663 | "\n",
|
664 | 664 | "if hasattr(tqdm, '_instances'): tqdm._instances.clear() # clear if it exists\n",
|
|
686 | 686 | " grads = # TODO\n",
|
687 | 687 | " optimizer.apply_gradients(zip(grads, cnn_model.trainable_variables))\n",
|
688 | 688 | "\n",
|
| 689 | + "comet_model_3.log_figure(figure=plt)\n", |
689 | 690 | "comet_model_3.end()\n"
|
690 | 691 | ]
|
691 | 692 | },
|
|
0 commit comments