Skip to content

Instantly share code, notes, and snippets.

View andreaskoepf's full-sized avatar

Andreas Köpf andreaskoepf

View GitHub Profile
@andreaskoepf
andreaskoepf / JobQueue.cs
Last active October 22, 2015 21:24
Rx JobQueue
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Threading;
@andreaskoepf
andreaskoepf / rotationdistance.lua
Created October 19, 2015 22:26
experimental torch rotation distance criterion for quaternions
local RotationDistance, parent = torch.class('RotationDistance', 'nn.Criterion')
function RotationDistance:__init(weights)
parent.__init(self)
end
function RotationDistance:updateOutput(input, target)
-- acos(abs(<a,b> / norm(a) / norm(b))) + abs(1 - norm(a))
local one = torch.ones(input:size(1)):cuda()
local a = torch.cmul(input, target):sum(2):cdiv(torch.cmul(input:norm(2, 2), target:norm(2, 2))):abs():clamp(-1, 1):acos()
@andreaskoepf
andreaskoepf / bottleneck_autoencoder.lua
Created September 16, 2015 01:03
mini bottleneck auto-encoder weight tying demo
require 'nn'
-- mini bottleneck auto-encoder weight tying demo
net = nn.Sequential()
net:add(nn.Linear(8, 8))
net:add(nn.PReLU())
net:add(nn.Linear(8, 3))
net:add(nn.PReLU())
net:add(nn.Linear(3, 8))
@andreaskoepf
andreaskoepf / conv_autoencoder.lua
Created September 16, 2015 00:57
mini single layer denoising auto-encoder experiment
require 'image'
require 'nngraph'
require 'optim'
-- mini single layer denoising auto-encoder experiment
-- (v1: no weight tying yet)
-- Andreas Köpf 2015-09-16
input = image.lena() -- 3x512x512
input_size = input:size()