|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Convolutional Neural Network" |
| 8 | + ] |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "code", |
| 12 | + "execution_count": 2, |
| 13 | + "metadata": { |
| 14 | + "collapsed": false |
| 15 | + }, |
| 16 | + "outputs": [ |
| 17 | + { |
| 18 | + "name": "stdout", |
| 19 | + "output_type": "stream", |
| 20 | + "text": [ |
| 21 | + "X_val has shape: (1000, 3, 32, 32)\n", |
| 22 | + "X_train has shape: (49000, 3, 32, 32)\n", |
| 23 | + "X_test has shape: (1000, 3, 32, 32)\n", |
| 24 | + "y_val has shape: (1000,)\n", |
| 25 | + "y_train has shape: (49000,)\n", |
| 26 | + "y_test has shape: (1000,)\n" |
| 27 | + ] |
| 28 | + } |
| 29 | + ], |
| 30 | + "source": [ |
| 31 | + "from data_utils import get_preprocessed_CIFAR10\n", |
| 32 | + "\n", |
| 33 | + "# Let's get some data in first\n", |
| 34 | + "feed_dict = get_preprocessed_CIFAR10('datasets/cifar-10-batches-py')\n", |
| 35 | + "\n", |
| 36 | + "for key, value in feed_dict.iteritems():\n", |
| 37 | + " print \"%s has shape: %s\" % (key, value.shape)" |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + "cell_type": "code", |
| 42 | + "execution_count": null, |
| 43 | + "metadata": { |
| 44 | + "collapsed": false |
| 45 | + }, |
| 46 | + "outputs": [ |
| 47 | + { |
| 48 | + "name": "stdout", |
| 49 | + "output_type": "stream", |
| 50 | + "text": [ |
| 51 | + "(Iteration 1 / 1960) loss: 2.303022\n", |
| 52 | + "(Epoch 0 / 4) train acc: 0.123000; val_acc: 0.111000\n", |
| 53 | + "(Iteration 11 / 1960) loss: 2.291381\n", |
| 54 | + "(Iteration 21 / 1960) loss: 2.257190\n", |
| 55 | + "(Iteration 31 / 1960) loss: 2.203646\n", |
| 56 | + "(Iteration 41 / 1960) loss: 2.176024\n", |
| 57 | + "(Iteration 51 / 1960) loss: 2.069092\n", |
| 58 | + "(Iteration 61 / 1960) loss: 2.036589\n", |
| 59 | + "(Iteration 71 / 1960) loss: 1.912840\n", |
| 60 | + "(Iteration 81 / 1960) loss: 1.929446\n", |
| 61 | + "(Iteration 91 / 1960) loss: 1.831559\n", |
| 62 | + "(Iteration 101 / 1960) loss: 1.787254\n", |
| 63 | + "(Iteration 111 / 1960) loss: 1.776150\n", |
| 64 | + "(Iteration 121 / 1960) loss: 1.642039" |
| 65 | + ] |
| 66 | + } |
| 67 | + ], |
| 68 | + "source": [ |
| 69 | + "from conv_net_model import ConvNetModel\n", |
| 70 | + "from solver import Solver\n", |
| 71 | + "import time\n", |
| 72 | + "\n", |
| 73 | + "# Define the model\n", |
| 74 | + "model = ConvNetModel()\n", |
| 75 | + "t0 = time.time()\n", |
| 76 | + "solver = Solver(model, \n", |
| 77 | + " feed_dict, \n", |
| 78 | + " update_rule='sgd_momentum', \n", |
| 79 | + " num_epochs=4, \n", |
| 80 | + " batch_size=100, \n", |
| 81 | + " optim_config={'learning_rate': 1e-3},\n", |
| 82 | + " verbose=True)\n", |
| 83 | + "solver.train()\n", |
| 84 | + "tf = time.time()" |
| 85 | + ] |
| 86 | + }, |
| 87 | + { |
| 88 | + "cell_type": "code", |
| 89 | + "execution_count": null, |
| 90 | + "metadata": { |
| 91 | + "collapsed": true |
| 92 | + }, |
| 93 | + "outputs": [], |
| 94 | + "source": [] |
| 95 | + } |
| 96 | + ], |
| 97 | + "metadata": { |
| 98 | + "kernelspec": { |
| 99 | + "display_name": "Python 2", |
| 100 | + "language": "python", |
| 101 | + "name": "python2" |
| 102 | + }, |
| 103 | + "language_info": { |
| 104 | + "codemirror_mode": { |
| 105 | + "name": "ipython", |
| 106 | + "version": 2 |
| 107 | + }, |
| 108 | + "file_extension": ".py", |
| 109 | + "mimetype": "text/x-python", |
| 110 | + "name": "python", |
| 111 | + "nbconvert_exporter": "python", |
| 112 | + "pygments_lexer": "ipython2", |
| 113 | + "version": "2.7.6" |
| 114 | + } |
| 115 | + }, |
| 116 | + "nbformat": 4, |
| 117 | + "nbformat_minor": 0 |
| 118 | +} |
0 commit comments