- Use SSHFS (installed with Homebrew) to browse remote files
atom-beautifyautopep8through Anacondauncrustifythrough Homebrew
Linterlinter-clang
linter-cppcheck
| from theano import tensor | |
| from blocks.bricks import Linear, Rectifier, Softmax | |
| from blocks.bricks.cost import CategoricalCrossEntropy | |
| from blocks.roles import WEIGHT | |
| from blocks.graph import ComputationGraph | |
| from blocks.filter import VariableFilter | |
| from blocks.initialization import IsotropicGaussian, Constant | |
| from blocks.algorithms import GradientDescent, Scale | |
| from blocks.log.log import TrainingLog |
| import theano | |
| from theano import tensor | |
| import numpy as np | |
| def main(): | |
| x = tensor.vector('x') | |
| y = tensor.alloc(np.float32(0), *x.shape) | |
| def step(x_elem, t, prev_y): | |
| new_y = tensor.set_subtensor(prev_y[t], x_elem) |
| t = require 'torch' | |
| grad = require 'autograd' | |
| function loop(p, y, idxs) | |
| -- Only works if h is a derivable value as well | |
| x = p.x | |
| h = p.h | |
| for i = 1, x:size(1) do | |
| h[idxs[i]] = x[i] | |
| end |
| import sys | |
| import theano | |
| from theano import tensor | |
| import numpy as np | |
| def main(length): | |
| # Sequential input | |
| x = tensor.vector('x') |
| t = require 'torch' | |
| grad = require 'autograd' | |
| function loop(x, h, y, idxs) | |
| for i = 1, x:size(1) do | |
| h[idxs[i]] = x[i] | |
| if i == 1 then | |
| cost = t.pow(y[idxs[i]] - h[idxs[i]], 2) | |
| else | |
| cost = cost + t.pow(y[idxs[i]] - h[idxs[i]], 2) |
| grad = require 'autograd' | |
| torch = require 'torch' | |
| params={ | |
| W=torch.range(0, 8):view(3, 3), | |
| storage=torch.zeros(3, 3) | |
| } | |
| function f(params, x) | |
| params.storage[2] = params.W * x |
| import numpy | |
| import theano | |
| from theano import tensor, config | |
| # The parameters | |
| W = theano.shared(numpy.arange(9, dtype=config.floatX).reshape(3, 3)) | |
| storage = theano.shared(numpy.zeros((3, 3), dtype=config.floatX)) | |
| # The input | |
| x = tensor.vector('x') |
| local ffi = require 'ffi' | |
| ffi.cdef([[ | |
| typedef long time_t; | |
| typedef struct timeval { | |
| time_t tv_sec; | |
| time_t tv_usec; | |
| }; |
| local function nll(params, probs, out_arcs, out_mask, lengths) | |
| local seq_len = probs:size(1) | |
| local max_out_arcs = out_arcs:size(2) | |
| local state_nll = {0} | |
| for i = 1, seq_len do | |
| for j = 1, max_out_arcs do | |
| if out_mask[{i, j}] ~= 1 then | |
| break | |
| end | |
| local target = i + lengths[out_arcs[{i, j}]] |