A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| local function ConvertBNcudnn2nn(net) | |
| local function ConvertModule(net) | |
| return net:replace(function(x) | |
| if torch.type(x) == 'cudnn.BatchNormalization' then | |
| return cudnn.convert(x, nn) | |
| else | |
| return x | |
| end | |
| end) | |
| end |
| function svhn_convert_json(path) | |
| % convert .mat to json files | |
| %% Create .json file | |
| if isempty(path) | |
| error('Must specify a path to the dataset') | |
| end | |
| local function dimnarrow(x,sz,pad,dim) | |
| local xn = x | |
| for i=1,x:dim() do | |
| if i > dim then | |
| xn = xn:narrow(i,pad[i]+1,sz[i]) | |
| end | |
| end | |
| return xn | |
| end |
| -- Use three (consecutive) points to fit a 1D parabola | |
| -- and return its maximum value. To achieve sub-pixel | |
| -- precision for a 2D maxima (x,y), just fit the parabola over the | |
| -- x and y coordinates separately with two neighboring points. | |
| local function fitParabola(x1,x2,x3,y1,y2,y3) | |
| local x1_sqr = x1*x1 | |
| local x2_sqr = x2*x2 | |
| local x3_sqr = x3*x3 | |
| local div = (x1_sqr-x1*(x2+x3)+x2*x3)*(x2-x3) |
| local SplitTable, parent = torch.class('nn.MySplitTable', 'nn.Module') | |
| function SplitTable:__init(dimension, nTensors) | |
| parent.__init(self) | |
| self.dimension = dimension | |
| self.nTensors = nTensors | |
| self.joinTable = nn.JoinTable(dimension) | |
| end | |
| function SplitTable:getSize(input) |
rebase vs merge).rebase vs merge)reset vs checkout vs revert)git rev-parse)pull vs fetch)stash vs branch)reset vs checkout vs revert)git reset vs git rm --cached)