{"__v":1,"_id":"55314042d587b521004f658f","initVersion":{"_id":"552ca79368b9a02100718485","version":"0.0.6"},"project":"5503ea178c5e913700362c70","tags":[],"user":{"_id":"5503e897e508a017002013bd","username":"","name":"Markus Beissinger"},"createdAt":"2015-04-17T17:17:54.982Z","changelog":[],"body":"Debugging deep nets it hard. That's why we are introducing Monitor objects that let you evaluate expressions and variables from your model in real time during training and testing!\n\nHere's how it works:\n* You create a Monitor object with a string name (so you remember what the value represents), a Theano expression to evaluate during the model's training, and optionally which datasets (train, valid, test) you want to evaluate the expression on.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import theano.tensor as T\\nfrom opendeep.monitor.monitor import Monitor\\n\\nweights_mean = T.mean(self.weights)\\nweights_std  = T.std(self.weights)\\nmean_monitor = Monitor(name=\\\"mean\\\", expression=weights_mean, train=True)\\nstd_monitor = Monitor(name=\\\"std\\\", expression=weights_std, train=True)\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\n* You group similar Monitors into a MonitorsChannel object (think of it as a single graph, where each monitor in the channel gets plotted).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"from opendeep.monitor.monitor import MonitorsChannel\\n\\nweights_channel = MonitorsChannel(name=\\\"weights\\\", monitors=[mean_monitor, std_monitor])\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\n* You (optionally) create a Plot object from these MonitorsChannels, which takes care of plotting the values in real time using [Bokeh](http://bokeh.pydata.org/en/latest/).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"from opendeep.monitor.plot import Plot\\n\\nplot = Plot(bokeh_doc_name=\\\"Plotting!\\\", monitor_channels=[weights_channel])\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\n* These MonitorsChannels and/or Plot gets passed to the .train() function of the Optimizer! (If you want to use the plot, it is better to start bokeh-server from the command line first).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"bokeh-server\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"from opendeep.optimization.adadelta import AdaDelta\\n\\noptimizer = AdaDelta(model=your_model, loss=your_loss, dataset=your_dataset)\\n\\n# if you want to use the plotting\\noptimizer.train(plot=plot)\\n\\n# if you just want the monitors evaluated and logged\\noptimizer.train(monitor_channels=[weights_channel])\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\nFinally, a monitor known as train_cost will always be evaluated (even if you don't input any Monitor objects)! This is the cost expression your model is using for training.\n\nHere are some example plots from the [Monitors and Live Plotting guide](doc:monitors-and-live-plotting):\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/vZ0FgODOS0234rIbIK4R_monitor_tutorial_train.png\",\n        \"monitor_tutorial_train.png\",\n        \"600\",\n        \"600\",\n        \"#6e8594\",\n        \"\"\n      ],\n      \"caption\": \"Plotting MLP train cost.\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/DkorOoUTUqeNlwpdcC3A_monitor_tutorial_error.png\",\n        \"monitor_tutorial_error.png\",\n        \"600\",\n        \"600\",\n        \"#2f4a5b\",\n        \"\"\n      ],\n      \"caption\": \"Plotting MLP softmax classification error on train, valid, and test sets.\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/xAeJdaDRnmDYrnNwgThp_monitor_tutorial_weights.png\",\n        \"monitor_tutorial_weights.png\",\n        \"600\",\n        \"600\",\n        \"#3e88be\",\n        \"\"\n      ],\n      \"caption\": \"Plotting the mean values of MLP weights matrices.\"\n    }\n  ]\n}\n[/block]","slug":"tracking-important-values-with-monitors-monitorsch","title":"Tracking important values with Monitors, MonitorsChannel, and Plots!"}

Tracking important values with Monitors, MonitorsChannel, and Plots!


Debugging deep nets it hard. That's why we are introducing Monitor objects that let you evaluate expressions and variables from your model in real time during training and testing! Here's how it works: * You create a Monitor object with a string name (so you remember what the value represents), a Theano expression to evaluate during the model's training, and optionally which datasets (train, valid, test) you want to evaluate the expression on. [block:code] { "codes": [ { "code": "import theano.tensor as T\nfrom opendeep.monitor.monitor import Monitor\n\nweights_mean = T.mean(self.weights)\nweights_std = T.std(self.weights)\nmean_monitor = Monitor(name=\"mean\", expression=weights_mean, train=True)\nstd_monitor = Monitor(name=\"std\", expression=weights_std, train=True)", "language": "python" } ] } [/block] * You group similar Monitors into a MonitorsChannel object (think of it as a single graph, where each monitor in the channel gets plotted). [block:code] { "codes": [ { "code": "from opendeep.monitor.monitor import MonitorsChannel\n\nweights_channel = MonitorsChannel(name=\"weights\", monitors=[mean_monitor, std_monitor])", "language": "python" } ] } [/block] * You (optionally) create a Plot object from these MonitorsChannels, which takes care of plotting the values in real time using [Bokeh](http://bokeh.pydata.org/en/latest/). [block:code] { "codes": [ { "code": "from opendeep.monitor.plot import Plot\n\nplot = Plot(bokeh_doc_name=\"Plotting!\", monitor_channels=[weights_channel])", "language": "python" } ] } [/block] * These MonitorsChannels and/or Plot gets passed to the .train() function of the Optimizer! (If you want to use the plot, it is better to start bokeh-server from the command line first). [block:code] { "codes": [ { "code": "bokeh-server", "language": "shell" } ] } [/block] [block:code] { "codes": [ { "code": "from opendeep.optimization.adadelta import AdaDelta\n\noptimizer = AdaDelta(model=your_model, loss=your_loss, dataset=your_dataset)\n\n# if you want to use the plotting\noptimizer.train(plot=plot)\n\n# if you just want the monitors evaluated and logged\noptimizer.train(monitor_channels=[weights_channel])", "language": "python" } ] } [/block] Finally, a monitor known as train_cost will always be evaluated (even if you don't input any Monitor objects)! This is the cost expression your model is using for training. Here are some example plots from the [Monitors and Live Plotting guide](doc:monitors-and-live-plotting): [block:image] { "images": [ { "image": [ "https://files.readme.io/vZ0FgODOS0234rIbIK4R_monitor_tutorial_train.png", "monitor_tutorial_train.png", "600", "600", "#6e8594", "" ], "caption": "Plotting MLP train cost." } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/DkorOoUTUqeNlwpdcC3A_monitor_tutorial_error.png", "monitor_tutorial_error.png", "600", "600", "#2f4a5b", "" ], "caption": "Plotting MLP softmax classification error on train, valid, and test sets." } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/xAeJdaDRnmDYrnNwgThp_monitor_tutorial_weights.png", "monitor_tutorial_weights.png", "600", "600", "#3e88be", "" ], "caption": "Plotting the mean values of MLP weights matrices." } ] } [/block]