Skip to content

Instantly share code, notes, and snippets.

View JoostvDoorn's full-sized avatar

Joost van Doorn JoostvDoorn

View GitHub Profile
@JoostvDoorn
JoostvDoorn / README.md
Last active November 30, 2016 05:21
hiddenOutput cudnn LSTM

Simple test to figure out the format of hiddenOutput of cudnn LSTM, see the file below.

hiddenOutput of normal LSTM

(1,.,.) =
  0.3042  0.3042  0.3042
[torch.CudaTensor of size 1x1x3]

hiddenOutput of bidirection LSTM

@JoostvDoorn
JoostvDoorn / convert.lua
Created September 13, 2016 10:02
Conversion between SeqLSTM and cudnn LSTM
--
-- Author: Joost van Doorn <joost.vandoorn@student.uva.nl>
--
require 'rnn'
require 'cudnn'
function toCudnnLSTM(seqLSTM)
local rnn = cudnn.LSTM(seqLSTM.inputsize, seqLSTM.outputsize, 1)
local H, R, D = seqLSTM.outputsize, seqLSTM.outputsize, seqLSTM.inputsize
local biases = rnn:biases()
@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 = {}
0.023262095961369
0.043782837063209
0.092482087101952
0.18747380309514
0.36381674030978
0.70580721911491
1.1544929836985
1.7231447811158
2.396492313429
2.9533659130322
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
@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')
@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'
local rnntest = {}
local precision = 1e-5
local mytester
local benchmark = false
local makeOldRecurrent_isdone = false
function rnntest.encoderdecoder()
torch.manualSeed(123)
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;
@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