This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| newMap = containers.Map('KeyType','int32','ValueType','single'); | |
| val = 5; | |
| if (~isKey(newMap, 31)) | |
| newMap(31)=val; | |
| else | |
| newMap(31)=newMap(31) + val; | |
| end | |
| newMap(31) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:window.location="https://gmail.com/#search/rfc822msgid:"+encodeURIComponent(window.document.body.innerHTML.match(/Message-Id: <(.*)>/)[1])+"/"+encodeURIComponent(window.location.search.toString().slice(1).split('&').filter(function(x){return x.slice(0,3) == "th="})[0].slice(3)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jf = get(handle(gcf),'JavaFrame');pause(1e-5);jf.setMaximized(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = {'one' 'two' 'three'}; | |
| b = [1 2 3]; | |
| ab = cat(1, a, num2cell(b)); | |
| sprintf('%s = %d\n', ab{:}) | |
| %{ | |
| output: | |
| one = 1 | |
| two = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [ str ] = sprintf_vec( format, varargin ) | |
| %SPRINTF_VEC sprintf for vectors | |
| %vectors can be row vectors of column vectors as long as the dimension are | |
| % equal | |
| if (nargin == 0) %DEMO | |
| %{ | |
| format = '(%.2f,%.2f)=%.2f\n'; | |
| a = 1:10; | |
| b = 11:20; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % INSERT-SNIPPET | |
| % Insert a piece of code in the Matlab editor. | |
| % User Manual: | |
| % 1. Copy the code of this file. | |
| % 2. Create a new shortcut in Matlab (right click on the Shortcut toolbar > New Shortcut). | |
| % 3. Paste the code into 'Callback'. | |
| % 4. Change the code in the 22th line. | |
| % 5. Give a name to your shortcut in 'Label'. | |
| % 6. Click 'Save'. | |
| % 7. Click on the newly created shortcut to paste your code into the editor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [ret] = translate(value, leftMin, leftMax, rightMin, rightMax) | |
| % Figure out how 'wide' each range is | |
| leftSpan = leftMax - leftMin; | |
| rightSpan = rightMax - rightMin; | |
| % Convert the left range into a 0-1 range (float) | |
| valueScaled = (value - leftMin) / (leftSpan); | |
| % Convert the 0-1 range into a value in the right range. | |
| ret = rightMin + (valueScaled * rightSpan); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os,random | |
| os.environ["KERAS_BACKEND"] = "theano" | |
| os.environ["THEANO_FLAGS"] = "device=gpu,lib.cnmem=0.6" | |
| #os.environ["THEANO_FLAGS"] = "device=cpu" | |
| !nvidia-smi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #OBSOLETE: | |
| #http://stackoverflow.com/questions/32565829/simple-way-to-measure-cell-execution-time-in-ipython-notebook | |
| #%install_ext https://raw.github.com/cpcloud/ipython-autotime/master/autotime.py | |
| #use: pip install ipython-autotime | |
| %load_ext autotime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # revisiting the XOR and donut problems to show how features | |
| # can be learned automatically using neural networks. | |
| # | |
| # the notes for this class can be found at: | |
| # https://www.udemy.com/data-science-deep-learning-in-python | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| # for binary classification! no softmax here |