This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
local Foo, parent = torch.class('Foo') | |
Foo.__version = 1 | |
function Foo:__init() | |
parent.__init(self) | |
end | |
-- serialize 'old' object | |
old = Foo.new() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nn' | |
x = torch.rand(1,5,5) | |
a = nn.SpatialConvolution(1,1,3,3) | |
a.bias:zero() | |
ay1 =torch.xcorr2(x,a.weight,'V') | |
ay2 = a:forward(x) | |
b = nn.SpatialFullConvolution(1,1,3,3) | |
b.bias:zero() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local SpatialUnpooling, parent = torch.class('nn.SpatialUnpooling', 'nn.Module') | |
function SpatialUnpooling:__init(kW, kH, dW, dH, padW, padH) | |
parent.__init(self) | |
self.dW = dW or kW | |
self.dH = dH or kH | |
self.padW = padW or 0 | |
self.padH = padH or 0 | |
self.indices = torch.LongTensor() | |
self._indexTensor = torch.LongTensor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local SpatialUnpooling, parent = torch.class('nn.SpatialUnpooling', 'nn.Module') | |
function SpatialUnpooling:__init(kW, kH, dW, dH, padW, padH) | |
parent.__init(self) | |
self.dW = dW or kW | |
self.dH = dH or kH | |
self.padW = padW or 0 | |
self.padH = padH or 0 | |
self.indices = torch.LongTensor() | |
self._indexTensor = torch.LongTensor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = torch.DoubleTensor() | |
y = torch.FloatTensor() | |
function testfunc(a,b) | |
return a + b | |
end | |
f = {} | |
f[x:type()] = {} | |
f[y:type()] = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cunn' | |
--test cuda & non-cuda version | |
function testVolumetricFullConvolution() | |
local input = torch.rand(1,2,10,10,10) * 2 - 1 | |
local a = nn.VolumetricFullConvolution(2,3, 3,3,3, 1,1,1) | |
local b = nn.VolumetricFullConvolution(2,3, 3,3,3, 1,1,1) | |
b:cuda() | |
b.weight = a.weight:cuda() |
OlderNewer