Skip to content

Instantly share code, notes, and snippets.

View soumith's full-sized avatar

Soumith Chintala soumith

View GitHub Profile
@soumith
soumith / torchmemtest.lua
Last active December 14, 2015 00:39
torch seems to have a memleak in this case, even though you'd expect it to not, with the collectgarbage()
require 'image'
local memTestClass = torch.class('image.memTestClass')
function memTestClass:__newindex__(key, value)
if type(key) == 'number' then
return 1 -- do this so that rawset isn't called anyways, stupid of me to miss this
else rawset(self, key, value) end
end
function testMemory()
n = 50000
@soumith
soumith / gist:6011923
Last active December 19, 2015 20:09 — forked from culurciello/gist:5189137
#!/usr/bin/env torch
require 'nn'
require 'image'
require 'xlua'
require 'pl'
opt = lapp[[
-t,--threads (default 8) number of threads
-p,--type (default float) float or cuda
@soumith
soumith / async-http-leak.lua
Last active January 1, 2016 13:19
testing async http mem leak
local async = require 'async'
local http = require 'socket.http'
local ltn12 = require 'ltn12'
function start()
local url = 'tcp://localhost:8082/'
while true do
print(os.date())
local response = {}
@soumith
soumith / tcp-memleaks.lua
Last active January 1, 2016 15:19
tcp-memleaks.lua
local tcp = require 'socket'
require 'sys'
function start()
while true do
print(os.date())
local conn = tcp.connect('localhost',8483)
conn:send('ealasjdiasldjeladj')
conn:close()
sys.sleep(0.01)
@soumith
soumith / gist:c5a7ac73e06aee39e48d
Created May 1, 2014 01:36
gist of using the *CUDA modules
features = nn.Sequential()
features:add(nn.Transpose({1,4},{1,3},{1,2}))
features:add(nn.SpatialConvolutionCUDA(fSize[1], fSize[2], 9, 9, 2, 2)) -- (111 - 9 + 2)/2 = 52
features:add(nn.Threshold(0,1e-6))
features:add(nn.SpatialMaxPoolingCUDA(2,2,2,2)) -- 26
features:add(nn.SpatialConvolutionCUDA(fSize[2], fSize[3], 5, 5)) -- 22
features:add(nn.Threshold(0,1e-6))
features:add(nn.SpatialMaxPoolingCUDA(2,2,2,2)) -- 11
features:add(nn.SpatialConvolutionCUDA(fSize[3], fSize[4], 4, 4)) -- 8
features:add(nn.Threshold(0,1e-6))
require 'torch'
require 'nn'
local mytester = torch.Tester()
local precision = 1e-5
local critest = {}
function critest.MSECriterion()
require 'torch'
require 'nn'
torch.setdefaulttensortype('torch.FloatTensor')
-------------- Model -------------------------
branch = nn.Sequential()
branch:add(nn.Linear(4,5))
branch:add(nn.Linear(5,1))
parallel=nn.Parallel(1,1);
require 'torch'
require 'nn'
torch.setdefaulttensortype('torch.FloatTensor')
frameSize = 4 -- each input frame has 4 numbers
hiddenSize = 5 -- each hidden layer has 5 units
outputSize = 1 -- each output layer has 1 output
-------------- Model -------------------------
mlp = nn.Sequential()
require 'torch'
require 'nn'
require 'sys'
torch.setdefaulttensortype('torch.FloatTensor')
numInputNodes=30
numBatches=64
numHidden1=64
numHidden2=128
numOutputNodes=1
dataset=torch.Tensor{
{742313794,6385273,1362403386,80,169085576,0,1698277100,451,0},
{742313860,6385273,1362403386,80,169085576,0,1698300945,452,0},
{742338872,6385273,167840643,137,169085576,0,1718221933,480,0},
{742338872,6385273,167926801,53,169085576,0,1718222057,471,0},
{742338872,6385273,167846975,8014,169085576,0,1718222380,487,0},
{742338872,641958438357784123396879472047392017641614042483,167846975,8014,169085576,0,1718222453,517,0},
{742338934,6385273,167926801,53,169085576,0,1718273961,472,0},
{742338934,641958438357784123396879472047392017641614042483,167846975,8014,169085576,0,1718275304,519,0},
{742338934,6385273,167840643,137,169085576,0,1718275541,483,0},