├── Conv_MNIST.ipynb ├── Dense_MNIST.ipynb ├── LICENSE └── README.md /Conv_MNIST.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "# Simple Convolutional network for MNIST by aluo\n", 12 | "\n", 13 | "%matplotlib inline\n", 14 | "# Inline plotting\n", 15 | "\n", 16 | "from __future__ import absolute_import\n", 17 | "from __future__ import division\n", 18 | "from __future__ import print_function\n", 19 | "# Import some stuff from future, or else the code doesn't work\n", 20 | "from IPython import display\n", 21 | "\n", 22 | "import argparse\n", 23 | "import sys\n", 24 | "import matplotlib.pyplot as plt" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "from tensorflow.examples.tutorials.mnist import input_data\n", 34 | "# Use the tensorflow MNIST downloader\n", 35 | "\n", 36 | "import tensorflow as tf\n", 37 | "FLAGS = None" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": null, 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "def main(_):\n", 47 | " train_phase = tf.placeholder(tf.bool)\n", 48 | " # The phase can be either training (network is learning) or inference (network is being used)\n", 49 | " # So the train_phase is either true or false\n", 50 | " # This will affect the application of batchnorm layers (not used) and dropout layers\n", 51 | " \n", 52 | " x = tf.placeholder(tf.float32, [None, 784])\n", 53 | " # Set a placeholder to take in input\n", 54 | " # Shape of input is a flattened 28 x 28 image, so 784 values\n", 55 | " \n", 56 | " digit_img = tf.reshape(x[0], [28, 28])\n", 57 | " \n", 58 | " x_img = tf.reshape(x, [-1, 28, 28, 1])\n", 59 | " # Reshape it into batchsize x 28 x 28 x 1 (because black & white)\n", 60 | " \n", 61 | " l_conv1 = tf.layers.conv2d(x_img, filters=32, kernel_size=(5, 5), padding='SAME', activation=tf.nn.relu)\n", 62 | " # First layer outputs 32 feature maps and applies relu\n", 63 | " \n", 64 | " l_conv2 = tf.layers.conv2d(l_conv1, filters=64, kernel_size=(5, 5), padding='SAME', activation=tf.nn.relu)\n", 65 | " # Second layer is a outputs 64 feature maps and applies relu\n", 66 | " \n", 67 | " l_norm1 = tf.layers.batch_normalization(l_conv2, training=train_phase)\n", 68 | " # Apply batch norm\n", 69 | " \n", 70 | " l_pool1 = tf.layers.max_pooling2d(l_norm1, pool_size=[2, 2], strides=2)\n", 71 | " # Apply pooling, reduces images size by factor 2 on each side, now is 14 x 14 x 64\n", 72 | " \n", 73 | " l_conv3 = tf.layers.conv2d(l_pool1, filters=32, kernel_size=(3, 3), padding='SAME', activation=tf.nn.relu)\n", 74 | " # Third layer is a outputs 32 feature maps and applies relu\n", 75 | " \n", 76 | " l_conv4 = tf.layers.conv2d(l_conv3, filters=16, kernel_size=(3, 3), padding='SAME', activation=tf.nn.relu)\n", 77 | " # Fourth layer is a outputs 16 feature maps and applies relu\n", 78 | " \n", 79 | " l_pool2 = tf.layers.max_pooling2d(l_conv4, pool_size=[2, 2], strides=2)\n", 80 | " # Pool again, now is 7 x 7 x 16\n", 81 | " \n", 82 | " l_flat1 = tf.reshape(l_pool2, [-1, 7 * 7 * 16])\n", 83 | " # Flatten the output of the previous layer\n", 84 | " \n", 85 | " l_dense1 = tf.layers.dense(l_flat1, units=512, activation=tf.nn.relu)\n", 86 | " # Dense layer with 512 neurons\n", 87 | " \n", 88 | " l_dropout1 = tf.layers.dropout(inputs=l_dense1, rate=0.25, training=train_phase)\n", 89 | " # Dropout 25%\n", 90 | " \n", 91 | " y_output = tf.layers.dense(l_dense1, units=10, activation=tf.nn.relu)\n", 92 | " # Finally, make sure the output layer has 10 neurons (corresponding to the numbers from 0...9)\n", 93 | " \n", 94 | " mnist = input_data.read_data_sets(FLAGS.data_dir, one_hot=True)\n", 95 | " # Import data, set the labels to be a one-hot encoding\n", 96 | " # So an image that represents 2\n", 97 | " # Will have a label that is [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]\n", 98 | " # Remember 0 is the first digit!\n", 99 | " \n", 100 | " y_ = tf.placeholder(tf.float32, [None, 10])\n", 101 | " # We define a place to input the label into the graph\n", 102 | " \n", 103 | " cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y_output))\n", 104 | " # Define a loss using cross-entropy \n", 105 | " # Basically measures how different is the predicted label is from the actual label\n", 106 | " # Take a mean across all 10 digits, could potentially also use a sum\n", 107 | " \n", 108 | " update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)\n", 109 | " # Ported over from conv example\n", 110 | " # Update Ops are required for batch_norm to work (moving average for batch mean & std)\n", 111 | " \n", 112 | " with tf.control_dependencies(update_ops):\n", 113 | " train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)\n", 114 | " # Choose how we want to optimize (Adam is usually a good choice)\n", 115 | " # And choose the loss that we want to minimize\n", 116 | "\n", 117 | " y_output_digit = tf.argmax(y_output, 1)\n", 118 | " y_digit = tf.argmax(y_, 1)\n", 119 | " correct_prediction = tf.equal(y_output_digit, y_digit)\n", 120 | " # Take the maximum probability as the predicted digits\n", 121 | " # For example, if the network predicts [0.1, 0.8, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]\n", 122 | " # Then we say that the network predicts the image represents a 1\n", 123 | " # We then compare this to y_ (the actual digit)\n", 124 | " # If they are the same, we count it as a correct prediction\n", 125 | " \n", 126 | " accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))\n", 127 | " # The accuracy is simply the correction predictions as a ratio of total predictions (batch size)\n", 128 | " step_holder = []\n", 129 | " accuracy_holder = []\n", 130 | " \n", 131 | " with tf.Session() as sess:\n", 132 | " sess.run(tf.global_variables_initializer())\n", 133 | " # Initialize the weights, offsets etc.\n", 134 | " \n", 135 | " for i in range(20000):\n", 136 | " batch = mnist.train.next_batch(32)\n", 137 | " # Get 32 images\n", 138 | " \n", 139 | " train_step.run(feed_dict={x: batch[0], y_: batch[1], train_phase: True})\n", 140 | " # Run a round of optimizations \n", 141 | " \n", 142 | " if i % 15 == 0:\n", 143 | " # Every 15 batches, we check on the accuracy\n", 144 | " step_holder.append(i)\n", 145 | " # Keep track of the steps\n", 146 | " \n", 147 | " train_accuracy = accuracy.eval(feed_dict={x: batch[0], y_: batch[1], train_phase: False})\n", 148 | " # Calculate the training_accuracy for the current batch\n", 149 | " \n", 150 | " accuracy_holder.append(train_accuracy)\n", 151 | " # Keep track of the current accuracy\n", 152 | " \n", 153 | " display.clear_output(wait=True)\n", 154 | " print('step {}, training accuracy {}'.format(i, train_accuracy))\n", 155 | " plt.subplot(1, 2, 1)\n", 156 | " plt.imshow(digit_img.eval(feed_dict={x:batch[0]}))\n", 157 | " plt.title(\"Predicted digit: {}\".format(y_output_digit.eval(feed_dict={x:batch[0],train_phase: False})[0]))\n", 158 | " plt.subplot(1, 2, 2)\n", 159 | " plt.plot(step_holder, accuracy_holder)\n", 160 | " plt.title(\"Accuracy vs training batches\")\n", 161 | " # Plotting stuff\n", 162 | " \n", 163 | " display.display(plt.gcf())\n", 164 | " plt.gcf().clear()" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": null, 170 | "metadata": {}, 171 | "outputs": [], 172 | "source": [ 173 | "if __name__ == '__main__':\n", 174 | " parser = argparse.ArgumentParser()\n", 175 | " parser.add_argument('--data_dir', type=str, default='/tmp/tensorflow/mnist/input_data', help='Directory for storing input data')\n", 176 | " FLAGS, unparsed = parser.parse_known_args()\n", 177 | " tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)" 178 | ] 179 | } 180 | ], 181 | "metadata": { 182 | "kernelspec": { 183 | "display_name": "Python 3", 184 | "language": "python", 185 | "name": "python3" 186 | }, 187 | "language_info": { 188 | "codemirror_mode": { 189 | "name": "ipython", 190 | "version": 3 191 | }, 192 | "file_extension": ".py", 193 | "mimetype": "text/x-python", 194 | "name": "python", 195 | "nbconvert_exporter": "python", 196 | "pygments_lexer": "ipython3", 197 | "version": "3.6.4" 198 | } 199 | }, 200 | "nbformat": 4, 201 | "nbformat_minor": 2 202 | } 203 | -------------------------------------------------------------------------------- /Dense_MNIST.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "# Simple MNIST network by aluo\n", 12 | "\n", 13 | "%matplotlib inline\n", 14 | "# Inline plotting\n", 15 | "\n", 16 | "from __future__ import absolute_import\n", 17 | "from __future__ import division\n", 18 | "from __future__ import print_function\n", 19 | "# Import some stuff from future, or else the code doesn't work\n", 20 | "from IPython import display\n", 21 | "\n", 22 | "import argparse\n", 23 | "import sys\n", 24 | "import matplotlib.pyplot as plt" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "from tensorflow.examples.tutorials.mnist import input_data\n", 34 | "# Use the tensorflow MNIST downloader\n", 35 | "\n", 36 | "import tensorflow as tf\n", 37 | "FLAGS = None" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": null, 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "def main(_):\n", 47 | " train_phase = tf.placeholder(tf.bool)\n", 48 | " # The phase can be either training (network is learning) or inference (network is being used)\n", 49 | " # So the train_phase is either true or false\n", 50 | " # This will affect the application of batchnorm layers (not used) and dropout layers\n", 51 | " \n", 52 | " x = tf.placeholder(tf.float32, [None, 784])\n", 53 | " # Set a placeholder to take in input\n", 54 | " # Shape of input is a flattened 28 x 28 image, so 784 values\n", 55 | " \n", 56 | " digit_img = tf.reshape(x[0], [28, 28])\n", 57 | " \n", 58 | " fc1 = tf.layers.dense(x, units=1024, activation=tf.nn.relu)\n", 59 | " # First layer is a 1024 neuron dense layer with relu\n", 60 | " \n", 61 | " fc2 = tf.layers.dense(fc1, units=512, activation=tf.nn.relu)\n", 62 | " # Followed by 512 neuron dense layer\n", 63 | " \n", 64 | " fc3 = tf.layers.dense(fc2, units=256, activation=tf.nn.relu)\n", 65 | " # Followed by 256 neuron dense layer\n", 66 | " \n", 67 | " h_dropout2 = tf.layers.dropout(inputs=fc3, rate=0.5, training=train_phase)\n", 68 | " # Dropout 50% of the neurons to prevent overfit\n", 69 | " \n", 70 | " y_output = tf.layers.dense(h_dropout2, units=10, activation=tf.nn.relu)\n", 71 | " # Finally, make sure the output layer has 10 neurons (corresponding to the numbers from 0...9)\n", 72 | " \n", 73 | " mnist = input_data.read_data_sets(FLAGS.data_dir, one_hot=True)\n", 74 | " # Import data, set the labels to be a one-hot encoding\n", 75 | " # So an image that represents 2\n", 76 | " # Will have a label that is [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]\n", 77 | " # Remember 0 is the first digit!\n", 78 | " \n", 79 | " y_ = tf.placeholder(tf.float32, [None, 10])\n", 80 | " # We define a place to input the label into the graph\n", 81 | " \n", 82 | " cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y_output))\n", 83 | " # Define a loss using cross-entropy \n", 84 | " # Basically measures how different is the predicted label is from the actual label\n", 85 | " # Take a mean across all 10 digits, could potentially also use a sum\n", 86 | " \n", 87 | " update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)\n", 88 | " # Ported over from conv example\n", 89 | " # Update Ops are required for batch_norm to work\n", 90 | " # Not necessary for dense layers\n", 91 | " \n", 92 | " with tf.control_dependencies(update_ops):\n", 93 | " train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)\n", 94 | " # Choose how we want to optimize (Adam is usually a good choice)\n", 95 | " # And choose the loss that we want to minimize\n", 96 | "\n", 97 | " y_output_digit = tf.argmax(y_output, 1)\n", 98 | " y_digit = tf.argmax(y_, 1)\n", 99 | " correct_prediction = tf.equal(y_output_digit, y_digit)\n", 100 | " # Take the maximum probability as the predicted digits\n", 101 | " # For example, if the network predicts [0.1, 0.8, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]\n", 102 | " # Then we say that the network predicts the image represents a 1\n", 103 | " # We then compare this to y_ (the actual digit)\n", 104 | " # If they are the same, we count it as a correct prediction\n", 105 | " \n", 106 | " accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))\n", 107 | " # The accuracy is simply the correction predictions as a ratio of total predictions (batch size)\n", 108 | " step_holder = []\n", 109 | " accuracy_holder = []\n", 110 | " \n", 111 | " with tf.Session() as sess:\n", 112 | " sess.run(tf.global_variables_initializer())\n", 113 | " # Initialize the weights, offsets etc.\n", 114 | " \n", 115 | " for i in range(20000):\n", 116 | " batch = mnist.train.next_batch(50)\n", 117 | " # Get 50 images\n", 118 | " \n", 119 | " train_step.run(feed_dict={x: batch[0], y_: batch[1], train_phase: True})\n", 120 | " # Run a round of optimizations \n", 121 | " \n", 122 | " if i % 100 == 0:\n", 123 | " # Every 100 batches, we check on the accuracy\n", 124 | " step_holder.append(i)\n", 125 | " # Keep track of the steps\n", 126 | " \n", 127 | " train_accuracy = accuracy.eval(feed_dict={x: batch[0], y_: batch[1], train_phase: False})\n", 128 | " # Calculate the training_accuracy for the current batch\n", 129 | " \n", 130 | " accuracy_holder.append(train_accuracy)\n", 131 | " # Keep track of the current accuracy\n", 132 | " \n", 133 | " display.clear_output(wait=True)\n", 134 | " print('step {}, training accuracy {}'.format(i, train_accuracy))\n", 135 | " plt.subplot(1, 2, 1)\n", 136 | " plt.imshow(digit_img.eval(feed_dict={x:batch[0]}))\n", 137 | " plt.title(\"Predicted digit: {}\".format(y_output_digit.eval(feed_dict={x:batch[0],train_phase: False})[0]))\n", 138 | " plt.subplot(1, 2, 2)\n", 139 | " plt.plot(step_holder, accuracy_holder)\n", 140 | " plt.title(\"Accuracy vs training batches\")\n", 141 | " # Plotting stuff\n", 142 | " \n", 143 | " display.display(plt.gcf())\n", 144 | " plt.gcf().clear()" 145 | ] 146 | }, 147 | { 148 | "cell_type": "code", 149 | "execution_count": null, 150 | "metadata": {}, 151 | "outputs": [], 152 | "source": [ 153 | "if __name__ == '__main__':\n", 154 | " parser = argparse.ArgumentParser()\n", 155 | " parser.add_argument('--data_dir', type=str, default='/tmp/tensorflow/mnist/input_data', help='Directory for storing input data')\n", 156 | " FLAGS, unparsed = parser.parse_known_args()\n", 157 | " tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)" 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": null, 163 | "metadata": { 164 | "collapsed": true 165 | }, 166 | "outputs": [], 167 | "source": [] 168 | } 169 | ], 170 | "metadata": { 171 | "kernelspec": { 172 | "display_name": "Python 3", 173 | "language": "python", 174 | "name": "python3" 175 | }, 176 | "language_info": { 177 | "codemirror_mode": { 178 | "name": "ipython", 179 | "version": 3 180 | }, 181 | "file_extension": ".py", 182 | "mimetype": "text/x-python", 183 | "name": "python", 184 | "nbconvert_exporter": "python", 185 | "pygments_lexer": "ipython3", 186 | "version": "3.6.4" 187 | } 188 | }, 189 | "nbformat": 4, 190 | "nbformat_minor": 2 191 | } 192 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Workshops 2 | ## Fall 2021 AI@MIT Workshops 3 | 4 | ### Workshop 6: PyTorch Lightning 5 | 6 | PyTorch Lightning: https://www.pytorchlightning.ai/ 7 | 8 | Solutions to the lab: https://colab.research.google.com/drive/12o9rI6EHu1CJPwwftcZVexCFGQYO7sI4?usp=sharing 9 | 10 | ### Workshop 5: Recurrent Neural Networks (RNNs) 11 | 12 | Slides: https://docs.google.com/presentation/d/1EeRSbkHdDjQkhKWNUxBa3NSZD7TFohwC/edit?usp=sharing&ouid=108062685813780551777&rtpof=true&sd=true 13 | 14 | Solutions to Lab: https://colab.research.google.com/drive/1hx6nCWROzPDZxWisoTdwX0blil3HWtji?usp=sharing 15 | 16 | ### Workshop 4: Convolutional Neural Networks (CNNs) 17 | 18 | Slides: https://docs.google.com/presentation/d/1e7BMYyVt9IDNWG1Mk4PwzbSR_vrWIYvQ/edit?usp=sharing&ouid=108062685813780551777&rtpof=true&sd=true 19 | 20 | Solutions to Lab: https://colab.research.google.com/drive/1zwJa-OSEL-tP72gej3oa8KLS--20lb3b?usp=sharing 21 | 22 | ### Workshop 3: End-to-End Training 23 | 24 | Solutions to Lab: https://tinyurl.com/aim21-f3-lab-solutions 25 | 26 | ### Workshop 2: PyTorch Abstractions + Deployment 27 | 28 | Slides: https://tinyurl.com/aim21-f2-slides 29 | 30 | Solutions to Lab: https://tinyurl.com/aim21-f2-lab-solutions 31 | 32 | ### Workshop 1: Introduction to Deep Learning + PyTorch 33 | 34 | Slides: https://tinyurl.com/workshop-1-presentation 35 | 36 | Solutions to Lab: https://tinyurl.com/workshop-1-solutions 37 | 38 | ## Spring 2021 AI@MIT Workshops 39 | 40 | ### Workshop 7: Style Transfer 41 | 42 | Slides: https://tinyurl.com/aim-w7-slides 43 | 44 | Lab: https://tinyurl.com/aim-w7-lab 45 | 46 | ### Workshop 8: Transfer Learning 47 | 48 | Slides: https://tinyurl.com/aim21-w8-slides 49 | 50 | Lab: https://tinyurl.com/aim21-w8-lab 51 | 52 | ### Workshop 9: Language Models and Transformers 53 | 54 | Slides: https://tinyurl.com/aim21-w9-slides 55 | 56 | Lab: https://tinyurl.com/aim21-w9-lab 57 | 58 | ### Workshop 10: Interpretability and Structure of Neural Networks 59 | 60 | Slides: https://tinyurl.com/aim21-w10-slides 61 | 62 | Lab: https://tinyurl.com/aim21-w10-labs 63 | 64 | Demo: https://tinyurl.com/aim21-w10-demo 65 | 66 | ### Workshop 11: Meta-Learning 67 | 68 | Slides: https://tinyurl.com/aim21-w11-slides 69 | 70 | Lab: https://tinyurl.com/aim21-w11-lab 71 | 72 | ## Fall 2020 AI@MIT Workshops 73 | 74 | ### Workshop 1: Deep Learning, Neural Networks and PyTorch 75 | Slides: https://tinyurl.com/aim-w1-pres 76 | 77 | Lab: http://tinyurl.com/aim-w1-lab 78 | 79 | Solutions to the lab: https://tinyurl.com/aim-w1-sol 80 | 81 | ### Workshop 2: Neural Networks Part 2: Optimization 82 | Slides: https://bit.ly/34axQtn 83 | 84 | Lab: https://bit.ly/3jiAt2z 85 | 86 | Solutions to the lab: https://bit.ly/33fkblu 87 | 88 | ### Workshop 3: Convolutional Neural Networks for Classification 89 | Slides: https://tinyurl.com/aim20w3slides 90 | 91 | Lab: https://tinyurl.com/aim20w3labs 92 | 93 | Solutions to the lab: https://tinyurl.com/aim20w3labsol 94 | 95 | ### Workshop 4: Recurrent Neural Networks and LSTMs 96 | Slides: https://tinyurl.com/aim20w4slides 97 | 98 | Lab: https://tinyurl.com/aim20w4labs 99 | 100 | Solutions to the lab: https://tinyurl.com/aim20w4labsol 101 | 102 | ### Workshop 5: Reinforcement Learning 103 | Slides: http://tinyurl.com/aim20w5slides 104 | 105 | Lab: https://tinyurl.com/aim20w5lab 106 | 107 | Solutions to the lab: https://tinyurl.com/aim20w5sol 108 | 109 | ### Workshop 6: Generative Adversarial Networks 110 | Slides: https://tinyurl.com/aim20slides 111 | 112 | Lab: https://tinyurl.com/aim20lab 113 | 114 | Solutions to the lab: https://tinyurl.com/aim20labsol 115 | 116 | ## Fall 2019 MIC Workshops 117 | 118 | ### Workshop 1: Deep Learning, Neural Networks and PyTorch 119 | Slides: http://bit.ly/ws1slides 120 | 121 | Lab: http://bit.ly/ws1colab 122 | 123 | Solutions to the lab: http://bit.ly/ws1sols 124 | 125 | ### Workshop 2: Neural Networks Part 2: Optimization 126 | Slides: http://bit.ly/micslides2 127 | 128 | Lab: http://bit.ly/micworkshop2 129 | 130 | Solutions to the lab: http://bit.ly/micsols2 131 | 132 | ### Workshop 3: Convolutional Neural Networks and Computer Vision 133 | Slides: http://bit.ly/micslides3 134 | 135 | Lab: https://bit.ly/2K2Vij0 136 | 137 | Solutions to the lab: https://tinyurl.com/y2zon8eo 138 | 139 | ### Workshop 4: Recurrent Neural Networks and LSTMs 140 | Slides: https://goo.gl/dP34S9 141 | 142 | Lab: https://goo.gl/1aer7H 143 | 144 | Solutions to the lab: https://tinyurl.com/yyobkzv8 145 | 146 | ### Workshop 5: Reinforcement Learning 147 | Slides: http://bit.ly/micslides5 148 | 149 | Lab: http://bit.ly/miclab5 150 | 151 | Solutions to the lab: http://bit.ly/miclab5sols 152 | 153 | ### Workshop 6: Generative Adversarial Networks 154 | Slides: http://tiny.cc/gans-slides 155 | 156 | Lab: http://tiny.cc/gans-lab 157 | 158 | Solutions to the lab: http://tiny.cc/gans-lab (code already working) 159 | 160 | 161 | ## Spring 2019 MIC Workshops 162 | 163 | ### Workshop 1: Deep Learning, Neural Networks and PyTorch 164 | Slides: https://goo.gl/v3e65W 165 | 166 | Lab: https://goo.gl/j3DAfE 167 | 168 | Solutions to the lab: https://tinyurl.com/y4o39o3e 169 | 170 | ### Workshop 2: Neural Networks Part 2: Optimization 171 | Slides: https://goo.gl/YmK5bB 172 | 173 | Lab: https://goo.gl/NZVVGR 174 | 175 | Solutions to the lab: https://tinyurl.com/yydqmvpr 176 | 177 | ### Workshop 3: Convolutional Neural Networks and Computer Vision 178 | Slides: https://goo.gl/cW2sMb 179 | 180 | Lab: https://goo.gl/VorvEb 181 | 182 | Solutions to the lab: https://tinyurl.com/y2zon8eo 183 | 184 | ### Workshop 4: Recurrent Neural Networks and LSTMs 185 | Slides: https://goo.gl/dP34S9 186 | 187 | Lab: https://goo.gl/1aer7H 188 | 189 | Solutions to the lab: https://tinyurl.com/yyobkzv8 190 | 191 | ### Workshop 5: Reinforcement Learning 192 | Slides: http://tinyurl.com/yxbjohaw 193 | 194 | Lab: https://goo.gl/fXJBp5 195 | 196 | Solutions to the lab: https://tinyurl.com/y48o7yjz 197 | 198 | ### Workshop 6: Generative Adversarial Networks 199 | Slides: http://tiny.cc/gans-slides 200 | 201 | Lab: http://tiny.cc/gans-lab 202 | 203 | Solutions to the lab: http://tiny.cc/gans-lab (code already working) 204 | 205 | ## Fall 2018 MIC Workshops 206 | ### Workshop 1: Deep Learning, Neural Networks and PyTorch 207 | Slides: https://goo.gl/dHHsai 208 | 209 | Code: https://goo.gl/j3DAfE 210 | 211 | ### Workshop 2: Neural Networks Part 2: Optimization 212 | Slides: https://goo.gl/DvWdgm 213 | 214 | Code: https://goo.gl/NZVVGR 215 | 216 | ### Workshop 3: Convolutional Neural Networks and Computer Vision 217 | Slides: https://goo.gl/iVzocJ 218 | 219 | Code: https://goo.gl/VorvEb 220 | 221 | ### Workshop 4: Recurrent Neural Networks and LSTMs 222 | Slides: https://goo.gl/QzVeJR 223 | 224 | Code: https://goo.gl/HZ4Q6F 225 | 226 | ### Workshop 5: Reinforcement Learning 227 | Slides: https://goo.gl/rUz4c7 228 | 229 | Code: https://goo.gl/fXJBp5 230 | 231 | ## Spring 2018 MIC Workshops 232 | 233 | ### Workshop 1: Deep Learning, Neural Networks and TensorFlow 234 | Slides: https://bit.ly/2qz4S2p 235 | 236 | Code: https://bit.ly/2JMu0vp 237 | 238 | ### Workshop 2: Optimization and Gradient Based Learning 239 | Slides: https://bit.ly/2qA0wbs 240 | 241 | Code: https://bit.ly/2ER9XZe 242 | 243 | ### Workshop 3: Convolutional Neural Networks 244 | Slides: https://bit.ly/2qAnj6W 245 | 246 | Code: https://bit.ly/2HoDWN9 247 | 248 | ### Workshop 4: Reinforcement Learning 249 | Slides: https://bit.ly/2KpXYFI 250 | 251 | Code: https://bit.ly/2HNToQP 252 | 253 | ### Workshop 5: Generative Adversarial Networks 254 | Slides: https://bit.ly/2IaD6nN 255 | 256 | ### Workshop 6: Recurrent Neural Networks 257 | Slides: https://bit.ly/2HM5zwR 258 | 259 | Code: https://bit.ly/2reL6JS 260 | --------------------------------------------------------------------------------