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
#!/usr/bin/env python | |
import subprocess | |
import re | |
class bcolors: | |
HEADER = '\033[95m' | |
OKBLUE = '\033[94m' | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' |
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
function removeDescriptors(net) | |
for i,val in pairs(net.modules) do | |
if tostring(val):find('cudnn') then | |
for name,field in pairs(val) do | |
if name:find('Desc') then | |
val[name] = nil | |
end | |
end | |
val.algType = nil | |
val.iDesc = nil |
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 1-th gpu | |
Loading ./data/ptb.train.txt, size of data = 929589 | |
Loading ./data/ptb.valid.txt, size of data = 73760 | |
Loading ./data/ptb.test.txt, size of data = 82430 | |
Network parameters: | |
{ | |
layers : 2 | |
lr : 1 | |
max_max_epoch : 13 | |
max_grad_norm : 5 |
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 1-th gpu | |
Loading ./data/ptb.train.txt, size of data = 929589 | |
Loading ./data/ptb.valid.txt, size of data = 73760 | |
Loading ./data/ptb.test.txt, size of data = 82430 | |
Network parameters: | |
{ | |
layers : 2 | |
lr : 1 | |
max_max_epoch : 13 | |
max_grad_norm : 5 |
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
-- a script to simplify trained net by incorporating every SpatialBatchNormalization to SpatialConvolution | |
-- and BatchNormalization to Linear | |
local function BNtoConv(net) | |
for i,v in ipairs(net.modules) do | |
if v.modules then | |
BNtoConv(v) | |
else | |
if torch.typename(v) == 'nn.SpatialBatchNormalization' and | |
(torch.typename(net:get(i-1)):find'SpatialConvolution') then |
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 Linear, parent = torch.class('nn.NoBiasLinear', 'nn.Linear') | |
function Linear:__init(inputSize, outputSize) | |
parent.__init(self, inputSize, outputSize) | |
self.bias:fill(0) | |
end | |
function Linear:accGradParameters(input, gradOutput, scale) | |
scale = scale or 1 | |
if input:dim() == 1 then |
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 BidirectionalSequencer, parent = torch.class('nn.BidirectionalSequencer', 'nn.Container') | |
function BidirectionalSequencer:__init(module_forward, module_backward, nOutputSize) | |
parent.__init(self) | |
self.module_forward = module_forward | |
self.module_backward = module_backward | |
self.modules[1] = nn.Sequencer(module_forward) | |
self.modules[2] = nn.Sequencer(module_backward) | |
self.output = {} |
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
-- Usage: | |
-- find . -name model.net -print0 | xargs -0 -n 1 th ~/clearState.lua | |
require 'cudnn' | |
local name = arg[1] | |
assert(paths.filep(name)) | |
print'before' |
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 'cv.highgui' | |
require 'cv.videoio' | |
require 'cv.imgproc' | |
require 'nn' | |
--require 'clnn' | |
local cap = cv.VideoCapture{device=0} | |
if not cap:isOpened() then | |
print("Failed to open the default camera") | |
os.exit(-1) |
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
function nn.Module:replace(callback) | |
local out = callback(self) | |
if self.modules then | |
for i, module in ipairs(self.modules) do | |
self.modules[i] = module:replace(callback) | |
end | |
end | |
return out | |
end |
OlderNewer