Skip to content

Instantly share code, notes, and snippets.

View JoostvDoorn's full-sized avatar

Joost van Doorn JoostvDoorn

View GitHub Profile
@JoostvDoorn
JoostvDoorn / gist:7560161
Created November 20, 2013 09:17
Canvas.hs drag example
import CanvasHs
import CanvasHs.Data
main = installEventHandler handl 1
-- we gebruiken een simpele Int als store (maar het zou ook een record oid kunnen zijn)
handl :: Int -> Event -> (Int, Shape)
handl st StartEvent  = (st, Container 900 600 [(Event defaults{eventId="123",mouseDrag=True} (Rect (34, 34) 34 200))
@JoostvDoorn
JoostvDoorn / gist:675ea988d8e713c4a8cd
Created October 15, 2015 14:10
Facebook Friends Ranking
javascript:function creator(e,t,n)%7Bvar r%3Ddocument.createElement(n)%3Br.cellspacing%3D"3"%3Bvar i%3Ddocument.createTextNode(t)%3Br.appendChild(i)%3Be.appendChild(r)%7Dfunction displayData(e)%7Bvar t%3Ddocument.createElement("table")%3Bvar n%3Ddocument.createElement("thead")%3Bt.appendChild(n)%3Bvar r%3Ddocument.createElement("tr")%3Bcreator(r,"Name","th")%3Bcreator(r,"Type","th")%3Bcreator(r,"Score","th")%3Bn.appendChild(r)%3Bvar s%3Ddocument.createElement("tbody")%3Bt.appendChild(s)%3Bfor(i%3D0%3Bi<e.length%3Bi%2B%2B)%7Bvar o%3De%5Bi%5D.type%3Bvar r%3Ddocument.createElement("tr")%3Bcreator(r,e%5Bi%5D%5B"text"%5D,"td")%3Bcreator(r,Object.keys(e%5Bi%5D%5B"grammar_costs"%5D)%5B0%5D.slice(0,-1).substring(1),"td")%3Bcreator(r,e%5Bi%5D%5B"grammar_costs"%5D%5BObject.keys(e%5Bi%5D%5B"grammar_costs"%5D)%5B0%5D%5D,"td")%3Bs.appendChild(r)%7Ddocument.body.innerHTML%3D""%3Bdocument.body.appendChild(t)%7Did%3DrequireDynamic("CurrentUserInitialData")%5B"USER_ID"%5D%7C%7CrequireDynamic("CurrentUserInitialData")%5B"ACCOU
@JoostvDoorn
JoostvDoorn / RegressionExample.java
Created November 5, 2015 19:30
Neural Network + Regression for Sin Function - Copy of http://pastebin.com/3uyKyCPU
package org.deeplearning4j.examples.regression
import org.canova.api.records.reader.RecordReader
import org.canova.api.records.reader.impl.CSVRecordReader
import org.canova.api.split.FileSplit
import org.deeplearning4j.datasets.canova.RecordReaderDataSetIterator
import org.deeplearning4j.datasets.iterator.DataSetIterator
import org.deeplearning4j.nn.api.OptimizationAlgorithm
import org.deeplearning4j.nn.conf.{ MultiLayerConfiguration, NeuralNetConfiguration }
import org.deeplearning4j.nn.conf.Updater
package Test;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.MethodDescriptor.generateFullMethodName;
local rnntest = {}
local precision = 1e-5
local mytester
local benchmark = false
local makeOldRecurrent_isdone = false
function rnntest.encoderdecoder()
torch.manualSeed(123)
@JoostvDoorn
JoostvDoorn / encoderdecodercoupling.lua
Last active November 30, 2016 05:21
cuDNN R5 RNN test
--[[
Example of "coupled" separate encoder and decoder networks using cudnn, e.g. for sequence-to-sequence networks.
]]--
require 'rnn'
require 'cunn'
require 'cudnn'
@JoostvDoorn
JoostvDoorn / SequencerCriterion.lua
Created May 21, 2016 10:12
Beam search for Elemental Research/RNN
------------------------------------------------------------------------
--[[ SequencerCriterion ]]--
-- Applies a criterion to each of the inputs and targets in the
-- corresponding input and target Tables.
-- Useful for nn.Repeater and nn.Sequencer.
-- WARNING : assumes that the decorated criterion is stateless, i.e.
-- the backward doesn't need to be preceded by a commensurate forward.
------------------------------------------------------------------------
local SequencerCriterion, parent = torch.class('nn.SequencerCriterion', 'nn.Criterion')
Copyright (c) 2016, Joost van Doorn
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source caode must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
0.023262095961369
0.043782837063209
0.092482087101952
0.18747380309514
0.36381674030978
0.70580721911491
1.1544929836985
1.7231447811158
2.396492313429
2.9533659130322
@JoostvDoorn
JoostvDoorn / siamese.lua
Created August 18, 2016 08:38
Simple Sentence Similarity Example with Siamese Encoder
-- Simple Sentence Similarity Example with Siamese Encoder
-- Author: Joost van Doorn (joostvandoorn.com)
require 'nn'
require 'rnn'
require 'io'
local pl = require 'pl'
local dl = require 'dataload'
-- Options
local opt = {}