Skip to content

Instantly share code, notes, and snippets.

@dusenberrymw
Created August 1, 2016 20:05
Show Gist options
  • Save dusenberrymw/71ad46ac59a6045899c2134c746c8e5e to your computer and use it in GitHub Desktop.
Save dusenberrymw/71ad46ac59a6045899c2134c746c8e5e to your computer and use it in GitHub Desktop.
{"paragraphs":[{"text":"%md\n## Quick Setup","dateUpdated":"2016-08-01T12:09:19-0700","config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/markdown","editorHide":true},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470078505348_-349631352","id":"20160801-120825_354862280","result":{"code":"SUCCESS","type":"HTML","msg":"<h2>Quick Setup</h2>\n"},"dateCreated":"2016-08-01T12:08:25-0700","dateStarted":"2016-08-01T12:09:17-0700","dateFinished":"2016-08-01T12:09:17-0700","status":"FINISHED","progressUpdateIntervalMs":500,"$$hashKey":"object:1214"},{"text":"import org.apache.sysml.api.mlcontext._\nimport org.apache.sysml.api.mlcontext.ScriptFactory._\n\n// Create a SystemML MLContext object\nval ml = new MLContext(sc)","dateUpdated":"2016-08-01T12:12:09-0700","config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/scala"},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470077100213_1176859647","id":"20160801-114500_265391886","result":{"code":"SUCCESS","type":"TEXT","msg":"import org.apache.sysml.api.mlcontext._\nimport org.apache.sysml.api.mlcontext.ScriptFactory._\nml: org.apache.sysml.api.mlcontext.MLContext = org.apache.sysml.api.mlcontext.MLContext@580181d5\n"},"dateCreated":"2016-08-01T11:45:00-0700","dateStarted":"2016-08-01T12:12:09-0700","dateFinished":"2016-08-01T12:12:10-0700","status":"FINISHED","progressUpdateIntervalMs":500,"$$hashKey":"object:1215","focus":true},{"text":"%md\n## Download Data - MNIST","dateUpdated":"2016-08-01T12:09:26-0700","config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/markdown","tableHide":false,"editorHide":true},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470078486268_-640132096","id":"20160801-120806_1124996388","result":{"code":"SUCCESS","type":"HTML","msg":"<h2>Download Data - MNIST</h2>\n"},"dateCreated":"2016-08-01T12:08:06-0700","dateStarted":"2016-08-01T12:09:24-0700","dateFinished":"2016-08-01T12:09:24-0700","status":"FINISHED","progressUpdateIntervalMs":500,"$$hashKey":"object:1216"},{"text":"%sh\nmkdir -p data/mnist/\ncd data/mnist/\ncurl -O http://pjreddie.com/media/files/mnist_train.csv\ncurl -O http://pjreddie.com/media/files/mnist_test.csv","dateUpdated":"2016-08-01T12:45:04-0700","config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/sh"},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470077253058_-677029120","id":"20160801-114733_1668781300","result":{"code":"INCOMPLETE","type":"TEXT","msg":" % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r 0 104M 0 65031 0 0 122k 0 0:14:30 --:--:-- 0:14:30 122k\r 0 104M 0 617k 0 0 413k 0 0:04:18 0:00:01 0:04:17 413k\r 1 104M 1 1541k 0 0 616k 0 0:02:53 0:00:02 0:02:51 616k\r 2 104M 2 2524k 0 0 721k 0 0:02:28 0:00:03 0:02:25 721k\r 3 104M 3 3739k 0 0 830k 0 0:02:08 0:00:04 0:02:04 830k\r 4 104M 4 5067k 0 0 921k 0 0:01:56 0:00:05 0:01:51 1004k\r 6 104M 6 6599k 0 0 1014k 0 0:01:45 0:00:06 0:01:39 1193k\r 7 104M 7 8184k 0 0 1091k 0 0:01:38 0:00:07 0:01:31 1329k\r 9 104M 9 9788k 0 0 1150k 0 0:01:32 0:00:08 0:01:24 1451k\r 10 104M 10 11.2M 0 0 1211k 0 0:01:28 0:00:09 0:01:19 1553k\r 12 104M 12 12.8M 0 0 1256k 0 0:01:25 0:00:10 0:01:15 1625k\r 13 104M 13 14.5M 0 0 1295k 0 0:01:22 0:00:11 0:01:11 1660k\r 15 104M 15 16.2M 0 0 1328k 0 0:01:20 0:00:12 0:01:08 1683k\r 17 104M 17 17.8M 0 0 1356k 0 0:01:18 0:00:13 0:01:05 1705k\r 18 104M 18 19.5M 0 0 1380k 0 0:01:17 0:00:14 0:01:03 1702k\r 20 104M 20 21.2M 0 0 1397k 0 0:01:16 0:00:15 0:01:01 1690k\r 21 104M 21 22.8M 0 0 1416k 0 0:01:15 0:00:16 0:00:59 1693k\r 23 104M 23 24.5M 0 0 1435k 0 0:01:14 0:00:17 0:00:57 1702k\r 24 104M 24 26.0M 0 0 1444k 0 0:01:14 0:00:18 0:00:56 1681k\r 26 104M 26 27.7M 0 0 1458k 0 0:01:13 0:00:19 0:00:54 1683k\r 28 104M 28 29.4M 0 0 1471k 0 0:01:12 0:00:20 0:00:52 1702k\r 29 104M 29 30.9M 0 0 1475k 0 0:01:12 0:00:21 0:00:51 1673k\r 31 104M 31 32.6M 0 0 1485k 0 0:01:12 0:00:22 0:00:50 1664k\r 32 104M 32 34.3M 0 0 1495k 0 0:01:11 0:00:23 0:00:48 1685k\r 34 104M 34 35.9M 0 0 1505k 0 0:01:11 0:00:24 0:00:47 1687k\r 36 104M 36 37.6M 0 0 1513k 0 0:01:10 0:00:25 0:00:45 1689k\r 37 104M 37 39.3M 0 0 1520k 0 0:01:10 0:00:26 0:00:44 1713k\r 39 104M 39 41.0M 0 0 1527k 0 0:01:10 0:00:27 0:00:43 1716k\r 40 104M 40 42.6M 0 0 1531k 0 0:01:09 0:00:28 0:00:41 1702k\r 42 104M 42 44.2M 0 0 1537k 0 0:01:09 0:00:29 0:00:40 1694k\r 43 104M 43 45.9M 0 0 1542k 0 0:01:09 0:00:30 0:00:39 1689k\r 45 104M 45 47.6M 0 0 1549k 0 0:01:09 0:00:31 0:00:38 1698k\r 47 104M 47 49.3M 0 0 1553k 0 0:01:08 0:00:32 0:00:36 1697k\r 48 104M 48 50.7M 0 0 1550k 0 0:01:08 0:00:33 0:00:35 1660k\r 50 104M 50 52.3M 0 0 1555k 0 0:01:08 0:00:34 0:00:34 1661k\r 51 104M 51 54.0M 0 0 1560k 0 0:01:08 0:00:35 0:00:33 1665k\r 53 104M 53 55.7M 0 0 1564k 0 0:01:08 0:00:36 0:00:32 1658k\r 54 104M 54 57.4M 0 0 1568k 0 0:01:08 0:00:37 0:00:31 1659k\r 56 104M 56 58.8M 0 0 1566k 0 0:01:08 0:00:38 0:00:30 1667k\r 57 104M 57 60.5M 0 0 1570k 0 0:01:08 0:00:39 0:00:29 1675k\r 59 104M 59 62.1M 0 0 1570k 0 0:01:08 0:00:40 0:00:28 1647k\r 61 104M 61 63.7M 0 0 1573k 0 0:01:07 0:00:41 0:00:26 1646k\r 62 104M 62 65.4M 0 0 1577k 0 0:01:07 0:00:42 0:00:25 1644k\r 64 104M 64 66.9M 0 0 1577k 0 0:01:07 0:00:43 0:00:24 1664k\r 65 104M 65 68.6M 0 0 1580k 0 0:01:07 0:00:44 0:00:23 1657k\r 67 104M 67 70.1M 0 0 1579k 0 0:01:07 0:00:45 0:00:22 1652k\r 68 104M 68 71.8M 0 0 1582k 0 0:01:07 0:00:46 0:00:21 1654k\r 70 104M 70 73.4M 0 0 1583k 0 0:01:07 0:00:47 0:00:20 1638k\r 71 104M 71 74.9M 0 0 1583k 0 0:01:07 0:00:48 0:00:19 1635k\r 73 104M 73 76.6M 0 0 1584k 0 0:01:07 0:00:49 0:00:18 1621k\r 74 104M 74 78.0M 0 0 1583k 0 0:01:07 0:00:50 0:00:17 1615k\r 76 104M 76 79.7M 0 0 1585k 0 0:01:07 0:00:51 0:00:16 1609k\r 77 104M 77 81.3M 0 0 1586k 0 0:01:07 0:00:52 0:00:15 1611k\r 79 104M 79 82.8M 0 0 1585k 0 0:01:07 0:00:53 0:00:14 1606k\r 80 104M 80 84.4M 0 0 1587k 0 0:01:07 0:00:54 0:00:13 1620k\r 82 104M 82 86.1M 0 0 1590k 0 0:01:07 0:00:55 0:00:12 1661k\r 84 104M 84 87.8M 0 0 1592k 0 0:01:07 0:00:56 0:00:11 1663k\r 85 104M 85 89.4M 0 0 1593k 0 0:01:07 0:00:57 0:00:10 1674k\r 87 104M 87 91.2M 0 0 1596k 0 0:01:07 0:00:58 0:00:09 1716k\r 88 104M 88 92.8M 0 0 1597k 0 0:01:06 0:00:59 0:00:07 1705kParagraph received a SIGTERM.\nExitValue: 143"},"dateCreated":"2016-08-01T11:47:33-0700","dateStarted":"2016-08-01T12:45:04-0700","dateFinished":"2016-08-01T12:46:05-0700","status":"FINISHED","progressUpdateIntervalMs":500,"$$hashKey":"object:1217","focus":true},{"text":"%md\n## SystemML Softmax Model","dateUpdated":"2016-08-01T12:09:33-0700","config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/markdown","editorHide":true},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470077585213_-255625617","id":"20160801-115305_1238768497","result":{"code":"SUCCESS","type":"HTML","msg":"<h2>SystemML Softmax Model</h2>\n"},"dateCreated":"2016-08-01T11:53:05-0700","dateStarted":"2016-08-01T12:09:31-0700","dateFinished":"2016-08-01T12:09:31-0700","status":"FINISHED","progressUpdateIntervalMs":500,"$$hashKey":"object:1218"},{"text":"%md\n### 1. Train","dateUpdated":"2016-08-01T12:09:39-0700","config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/markdown","editorHide":true},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470078533090_-1965729975","id":"20160801-120853_1833388030","result":{"code":"SUCCESS","type":"HTML","msg":"<h3>1. Train</h3>\n"},"dateCreated":"2016-08-01T12:08:53-0700","dateStarted":"2016-08-01T12:09:37-0700","dateFinished":"2016-08-01T12:09:37-0700","status":"FINISHED","progressUpdateIntervalMs":500,"$$hashKey":"object:1219"},{"text":"val scriptString = \"\"\"\nsource(\"mnist_softmax.dml\") as mnist_softmax\n\n# Read training data\ndata = read($data, format=\"csv\")\nn = nrow(data)\n\n# Extract images and labels\nimages = data[,2:ncol(data)]\nlabels = data[,1]\n\n# Scale images to [0,1], and one-hot encode the labels\nimages = images / 255.0\nlabels = table(seq(1, n), labels+1, n, 10)\n\n# Split into training (55,000 examples) and validation (5,000 examples)\nX = images[5001:nrow(images),]\nX_val = images[1:5000,]\ny = labels[5001:nrow(images),]\ny_val = labels[1:5000,]\n\n# Train\n[W, b] = mnist_softmax::train(X, y, X_val, y_val)\n\n# Write model out (we will extract these back into PySpark)\n#write(W, $Wout)\n#write(b, $bout)\n\nprint(\"\")\nprint(\"\")\n\"\"\"\nval script = dml(scriptString).in(\"$data\",\"data/mnist/mnist_train.csv\").out(\"W\", \"b\")\nval (_W, _b) = ml.execute(script).getTuple[Matrix, Matrix](\"W\", \"b\")","dateUpdated":"2016-08-01T12:42:15-0700","config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/scala"},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470078538502_-1427450939","id":"20160801-120858_4156530","dateCreated":"2016-08-01T12:08:58-0700","status":"FINISHED","progressUpdateIntervalMs":500,"$$hashKey":"object:1220","dateFinished":"2016-08-01T12:42:28-0700","dateStarted":"2016-08-01T12:42:15-0700","result":{"code":"SUCCESS","type":"TEXT","msg":"scriptString: String = \n\"\nsource(\"mnist_softmax.dml\") as mnist_softmax\n\n# Read training data\ndata = read($data, format=\"csv\")\nn = nrow(data)\n\n# Extract images and labels\nimages = data[,2:ncol(data)]\nlabels = data[,1]\n\n# Scale images to [0,1], and one-hot encode the labels\nimages = images / 255.0\nlabels = table(seq(1, n), labels+1, n, 10)\n\n# Split into training (55,000 examples) and validation (5,000 examples)\nX = images[5001:nrow(images),]\nX_val = images[1:5000,]\ny = labels[5001:nrow(images),]\ny_val = labels[1:5000,]\n\n# Train\n[W, b] = mnist_softmax::train(X, y, X_val, y_val)\n\n# Write model out (we will extract these back into PySpark)\n#write(W, $Wout)\n#write(b, $bout)\n\nprint(\"\")\nprint(\"\")\n\"\nscript: org.apache.sysml.api.mlcontext.Script = \nInputs:\n [1] (String) $data: data/mnist/mnist_train.csv\n\nOutputs:\n [1] W\n [2] b\n\n_W: org.apache.sysml.api.mlcontext.Matrix = Matrix: scratch_space//_p7393_9.31.116.142//_t0/temp3027_500190, [784 x 10, nnz=7840, blocks (1000 x 1000)], binaryblock, dirty\n_b: org.apache.sysml.api.mlcontext.Matrix = Matrix: scratch_space//_p7393_9.31.116.142//_t0/temp3028_500191, [1 x 10, nnz=10, blocks (1000 x 1000)], binaryblock, dirty\n"},"focus":true},{"config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/scala"},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470078691147_-960168205","id":"20160801-121131_1205577812","dateCreated":"2016-08-01T12:11:31-0700","status":"FINISHED","progressUpdateIntervalMs":500,"focus":true,"$$hashKey":"object:1689","dateUpdated":"2016-08-01T12:42:36-0700","dateFinished":"2016-08-01T12:42:37-0700","dateStarted":"2016-08-01T12:42:36-0700","result":{"code":"SUCCESS","type":"TEXT","msg":"W: org.apache.spark.sql.DataFrame = [ID: double, C1: double, C2: double, C3: double, C4: double, C5: double, C6: double, C7: double, C8: double, C9: double, C10: double]\nb: org.apache.spark.sql.DataFrame = [ID: double, C1: double, C2: double, C3: double, C4: double, C5: double, C6: double, C7: double, C8: double, C9: double, C10: double]\n"},"text":"val W = _W.asDataFrame\nval b = _b.asDataFrame"},{"config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/markdown","editorHide":true},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470080449377_1987535970","id":"20160801-124049_1901199297","dateCreated":"2016-08-01T12:40:49-0700","status":"FINISHED","progressUpdateIntervalMs":500,"focus":true,"$$hashKey":"object:1900","dateUpdated":"2016-08-01T12:42:52-0700","dateFinished":"2016-08-01T12:42:49-0700","dateStarted":"2016-08-01T12:42:49-0700","result":{"code":"SUCCESS","type":"HTML","msg":"<h3>3. Compute Test Accuracy</h3>\n"},"text":"%md\n### 3. Compute Test Accuracy"},{"config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true,"editorMode":"ace/mode/scala"},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470080569417_-224446230","id":"20160801-124249_1497749514","dateCreated":"2016-08-01T12:42:49-0700","status":"FINISHED","progressUpdateIntervalMs":500,"focus":true,"$$hashKey":"object:2042","dateUpdated":"2016-08-01T12:48:38-0700","dateFinished":"2016-08-01T12:48:40-0700","dateStarted":"2016-08-01T12:48:38-0700","result":{"code":"SUCCESS","type":"TEXT","msg":"scriptString: String = \n\"\nsource(\"mnist_softmax.dml\") as mnist_softmax\n\n# Read test data\ndata = read($data, format=\"csv\")\nn = nrow(data)\n\n# Extract images and labels\nX_test = data[,2:ncol(data)]\ny_test = data[,1]\n\n# Scale images to [0,1], and one-hot encode the labels\nX_test = X_test / 255.0\ny_test = table(seq(1, n), y_test+1, n, 10)\n\n# Read model coefficients\nW = read($W)\nb = read($b)\n\n# Eval on test set\nprobs = mnist_softmax::predict(X_test, W, b)\n[loss, accuracy] = mnist_softmax::eval(probs, y_test)\n\nprint(\"Test Accuracy: \" + accuracy)\n\nprint(\"\")\nprint(\"\")\n\"\nscript: org.apache.sysml.api.mlcontext.Script = \nInputs:\n [1] (String) $data: data/mnist/mnist_test.csv\n [2] (DataFrame) W: [ID: double, C1: double, C2: double, C3: double, C4: double, C5: double, C6: double, C7: double, ...\n [3] (DataFrame) b: [ID: double, C1: double, C2: double, C3: double, C4: double, C5: double, C6: double, C7: double, ...\n\nOutputs:\nNone\n\nres13: org.apache.sysml.api.mlcontext.MLResults = \nNone\n\n"},"text":"val scriptString = \"\"\"\nsource(\"mnist_softmax.dml\") as mnist_softmax\n\n# Read test data\ndata = read($data, format=\"csv\")\nn = nrow(data)\n\n# Extract images and labels\nX_test = data[,2:ncol(data)]\ny_test = data[,1]\n\n# Scale images to [0,1], and one-hot encode the labels\nX_test = X_test / 255.0\ny_test = table(seq(1, n), y_test+1, n, 10)\n\n# Read model coefficients\nW = read($W)\nb = read($b)\n\n# Eval on test set\nprobs = mnist_softmax::predict(X_test, W, b)\n[loss, accuracy] = mnist_softmax::eval(probs, y_test)\n\nprint(\"Test Accuracy: \" + accuracy)\n\nprint(\"\")\nprint(\"\")\n\"\"\"\nval script = dml(scriptString).in(Map(\"$data\" -> \"data/mnist/mnist_test.csv\", \"W\" -> W, \"b\" -> b))\nml.execute(script)"},{"config":{"colWidth":12,"graph":{"mode":"table","height":300,"optionOpen":false,"keys":[],"values":[],"groups":[],"scatter":{}},"enabled":true},"settings":{"params":{},"forms":{}},"jobName":"paragraph_1470080653301_1059014804","id":"20160801-124413_706384127","dateCreated":"2016-08-01T12:44:13-0700","status":"READY","progressUpdateIntervalMs":500,"focus":true,"$$hashKey":"object:2118"}],"name":"Softmax Demo","id":"2BUARWM5V","angularObjects":{"2BUK5DPJH:shared_process":[],"2BTBYJUFV:shared_process":[],"2BRZCQYJH:shared_process":[],"2BS8RDVUZ:shared_process":[],"2BTAB2MNZ:shared_process":[],"2BSSAGZP7:shared_process":[],"2BS8RC9G8:shared_process":[],"2BR8S5CTW:shared_process":[],"2BTQKBH6G:shared_process":[],"2BSYPJEUX:shared_process":[],"2BUQ2K9S5:shared_process":[],"2BUT9CRGG:shared_process":[],"2BUCMMA72:shared_process":[],"2BRXJKE5E:shared_process":[],"2BUA9VR2E:shared_process":[],"2BTFWV4RM:shared_process":[],"2BUBBQGBG:shared_process":[]},"config":{"looknfeel":"default"},"info":{}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment