Commit d77687a6 authored by Benjamin Graham's avatar Benjamin Graham Committed by Benjamin Thomas Graham
Browse files

Rename ValidConvolutions to SubmanifoldConvolutions, update for PyTorch 0.4 Tensor/Variable merge

parent 297e04c0
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
--[[ --[[
Assume all the inputs have identical SparseGrids and input[i].features:size(1) Assume all the inputs have identical SparseGrids and input[i].features:size(1)
Assume input[1].features:size(2) >= input[i].features:size(2) for all i=1,#input Assume input[1].features:size(2) >= input[i].features:size(2) for all i=1,#input
output.validRules is taken from input[1].validRules (could do set union?) output.submanifoldRules is taken from input[1].submanifoldRules (could do set union?)
(for resnets, make sure the residual link is input[2]) (for resnets, make sure the residual link is input[2])
]] ]]
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
Store Metadata relating to which spatial locations are active at each scale. Store Metadata relating to which spatial locations are active at each scale.
Convolutions and 'convolution reversing' deconvolutions Convolutions and 'convolution reversing' deconvolutions
all coexist within the same MetaData object as long as each spatial size all coexist within the same MetaData object as long as each spatial size
only occurs once. Valid convolutions do not change the spatial structure. only occurs once. Submanifold convolutions do not change the spatial structure.
Serialization is emulated by storing the pointer as an integer. Serialization is emulated by storing the pointer as an integer.
This is sufficient for mutithreaded batch preparation: each 'serialized' This is sufficient for mutithreaded batch preparation: each 'serialized'
......
...@@ -45,7 +45,7 @@ return function(sparseconvnet) ...@@ -45,7 +45,7 @@ return function(sparseconvnet)
function sparseconvnet.SparseVggNet(dimension,nInputPlanes,layers,opts) function sparseconvnet.SparseVggNet(dimension,nInputPlanes,layers,opts)
--[[ --[[
VGG style nets VGG style nets
Use valid convolutions Use submanifold convolutions
Also implements 'Plus'-augmented nets Also implements 'Plus'-augmented nets
]] ]]
local nPlanes=nInputPlanes local nPlanes=nInputPlanes
...@@ -57,20 +57,20 @@ return function(sparseconvnet) ...@@ -57,20 +57,20 @@ return function(sparseconvnet)
elseif x[1] == 'MP' then elseif x[1] == 'MP' then
m:add(sparseconvnet.MaxPooling(dimension,x[2],x[3])) m:add(sparseconvnet.MaxPooling(dimension,x[2],x[3]))
elseif x[1]=='C' and #x==2 then elseif x[1]=='C' and #x==2 then
m:add(sparseconvnet.ValidConvolution(dimension,nPlanes,x[2],3,false)) m:add(sparseconvnet.SubmanifoldConvolution(dimension,nPlanes,x[2],3,false))
nPlanes=x[2] nPlanes=x[2]
m:add(sparseconvnet.BatchNormReLU(nPlanes)) m:add(sparseconvnet.BatchNormReLU(nPlanes))
elseif x[1]=='C' and #x==3 then elseif x[1]=='C' and #x==3 then
m:add(sparseconvnet.ConcatTable() m:add(sparseconvnet.ConcatTable()
:add( :add(
sparseconvnet.Sequential() sparseconvnet.Sequential()
:add(sparseconvnet.ValidConvolution(dimension,nPlanes,x[2],3,false)) :add(sparseconvnet.SubmanifoldConvolution(dimension,nPlanes,x[2],3,false))
) )
:add( :add(
sparseconvnet.Sequential() sparseconvnet.Sequential()
:add(sparseconvnet.Convolution(dimension,nPlanes,x[3],3,2,false)) :add(sparseconvnet.Convolution(dimension,nPlanes,x[3],3,2,false))
:add(sparseconvnet.BatchNormReLU(x[3])) :add(sparseconvnet.BatchNormReLU(x[3]))
:add(sparseconvnet.ValidConvolution(dimension,x[3],x[3],3,false)) :add(sparseconvnet.SubmanifoldConvolution(dimension,x[3],x[3],3,false))
:add(sparseconvnet.BatchNormReLU(x[3])) :add(sparseconvnet.BatchNormReLU(x[3]))
:add(sparseconvnet.Deconvolution(dimension,x[3],x[3],3,2,false)) :add(sparseconvnet.Deconvolution(dimension,x[3],x[3],3,2,false))
)) ))
...@@ -81,28 +81,28 @@ return function(sparseconvnet) ...@@ -81,28 +81,28 @@ return function(sparseconvnet)
m:add(sparseconvnet.ConcatTable() m:add(sparseconvnet.ConcatTable()
:add( :add(
sparseconvnet.Sequential() sparseconvnet.Sequential()
:add(sparseconvnet.ValidConvolution(dimension,nPlanes,x[2],3,false)) :add(sparseconvnet.SubmanifoldConvolution(dimension,nPlanes,x[2],3,false))
) )
:add( :add(
sparseconvnet.Sequential() sparseconvnet.Sequential()
:add(sparseconvnet.Convolution(dimension,nPlanes,x[3],3,2,false)) :add(sparseconvnet.Convolution(dimension,nPlanes,x[3],3,2,false))
:add(sparseconvnet.BatchNormReLU(x[3])) :add(sparseconvnet.BatchNormReLU(x[3]))
:add(sparseconvnet.ValidConvolution(dimension,x[3],x[3],3,false)) :add(sparseconvnet.SubmanifoldConvolution(dimension,x[3],x[3],3,false))
:add(sparseconvnet.BatchNormReLU(x[3])) :add(sparseconvnet.BatchNormReLU(x[3]))
:add(sparseconvnet.Deconvolution(dimension,x[3],x[3],3,2,false)) :add(sparseconvnet.Deconvolution(dimension,x[3],x[3],3,2,false))
) )
:add(sparseconvnet.Sequential() :add(sparseconvnet.Sequential()
:add(sparseconvnet.Convolution(dimension,nPlanes,x[4],3,2,false)) :add(sparseconvnet.Convolution(dimension,nPlanes,x[4],3,2,false))
:add(sparseconvnet.BatchNormReLU(x[4])) :add(sparseconvnet.BatchNormReLU(x[4]))
:add(sparseconvnet.ValidConvolution(dimension,x[4],x[4],3,false)) :add(sparseconvnet.SubmanifoldConvolution(dimension,x[4],x[4],3,false))
:add(sparseconvnet.BatchNormReLU(x[4])) :add(sparseconvnet.BatchNormReLU(x[4]))
:add(sparseconvnet.Convolution(dimension,x[4],x[4],3,2,false)) :add(sparseconvnet.Convolution(dimension,x[4],x[4],3,2,false))
:add(sparseconvnet.BatchNormReLU(x[4])) :add(sparseconvnet.BatchNormReLU(x[4]))
:add(sparseconvnet.ValidConvolution(dimension,x[4],x[4],3,false)) :add(sparseconvnet.SubmanifoldConvolution(dimension,x[4],x[4],3,false))
:add(sparseconvnet.BatchNormReLU(x[4])) :add(sparseconvnet.BatchNormReLU(x[4]))
:add(sparseconvnet.Deconvolution(dimension,x[4],x[4],3,2,false)) :add(sparseconvnet.Deconvolution(dimension,x[4],x[4],3,2,false))
:add(sparseconvnet.BatchNormReLU(x[4])) :add(sparseconvnet.BatchNormReLU(x[4]))
:add(sparseconvnet.ValidConvolution(dimension,x[4],x[4],3,false)) :add(sparseconvnet.SubmanifoldConvolution(dimension,x[4],x[4],3,false))
:add(sparseconvnet.BatchNormReLU(x[4])) :add(sparseconvnet.BatchNormReLU(x[4]))
:add(sparseconvnet.Deconvolution(dimension,x[4],x[4],3,2,false)) :add(sparseconvnet.Deconvolution(dimension,x[4],x[4],3,2,false))
)) ))
...@@ -138,10 +138,10 @@ return function(sparseconvnet) ...@@ -138,10 +138,10 @@ return function(sparseconvnet)
:add( --convolutional connection :add( --convolutional connection
sparseconvnet.Sequential() sparseconvnet.Sequential()
:add(stride==1 and :add(stride==1 and
sparseconvnet.ValidConvolution(dimension,nPlanes,n,3,false) or sparseconvnet.SubmanifoldConvolution(dimension,nPlanes,n,3,false) or
sparseconvnet.Convolution(dimension,nPlanes,n,3,stride,false)) sparseconvnet.Convolution(dimension,nPlanes,n,3,stride,false))
:add(sparseconvnet.BatchNormReLU(n)) :add(sparseconvnet.BatchNormReLU(n))
:add(sparseconvnet.ValidConvolution( :add(sparseconvnet.SubmanifoldConvolution(
dimension,n,n,3,false))) dimension,n,n,3,false)))
:add(residual(nPlanes,n,stride)) :add(residual(nPlanes,n,stride))
) )
...@@ -150,10 +150,10 @@ return function(sparseconvnet) ...@@ -150,10 +150,10 @@ return function(sparseconvnet)
:add( --convolutional connection :add( --convolutional connection
sparseconvnet.Sequential() sparseconvnet.Sequential()
:add(sparseconvnet.BatchNormReLU(n)) :add(sparseconvnet.BatchNormReLU(n))
:add(sparseconvnet.ValidConvolution( :add(sparseconvnet.SubmanifoldConvolution(
dimension,nPlanes,n,3,false)) dimension,nPlanes,n,3,false))
:add(sparseconvnet.BatchNormReLU(n)) :add(sparseconvnet.BatchNormReLU(n))
:add(sparseconvnet.ValidConvolution( :add(sparseconvnet.SubmanifoldConvolution(
dimension,n,n,3,false)) dimension,n,n,3,false))
) )
:add(sparseconvnet.Identity()) :add(sparseconvnet.Identity())
...@@ -169,7 +169,7 @@ return function(sparseconvnet) ...@@ -169,7 +169,7 @@ return function(sparseconvnet)
end end
function sparseconvnet.SparseDenseNet(dimension,nInputPlanes,layers) function sparseconvnet.SparseDenseNet(dimension,nInputPlanes,layers)
--[[ --[[
SparseConvNet meets DenseNets using valid convolutions SparseConvNet meets DenseNets using submanifold convolutions
Could do with a less confusing name Could do with a less confusing name
]] ]]
local nPlanes=nInputPlanes local nPlanes=nInputPlanes
......
...@@ -8,7 +8,7 @@ return function(sparseconvnet) ...@@ -8,7 +8,7 @@ return function(sparseconvnet)
local C = sparseconvnet.C local C = sparseconvnet.C
local Convolution, parent = torch.class( local Convolution, parent = torch.class(
'sparseconvnet.ValidConvolution', 'nn.Module', sparseconvnet) 'sparseconvnet.SubmanifoldConvolution', 'nn.Module', sparseconvnet)
function Convolution:__init(dimension, nInputPlanes, nOutputPlanes, function Convolution:__init(dimension, nInputPlanes, nOutputPlanes,
filterSize, bias) filterSize, bias)
...@@ -52,7 +52,7 @@ return function(sparseconvnet) ...@@ -52,7 +52,7 @@ return function(sparseconvnet)
self.output.spatialSize = input.spatialSize self.output.spatialSize = input.spatialSize
self.shared.forwardPassMultiplyAddCount= self.shared.forwardPassMultiplyAddCount=
self.shared.forwardPassMultiplyAddCount+ self.shared.forwardPassMultiplyAddCount+
C.dimTypedFn(self.dimension, self._type, 'ValidConvolution_updateOutput')( C.dimTypedFn(self.dimension, self._type, 'SubmanifoldConvolution_updateOutput')(
input.spatialSize:cdata(), input.spatialSize:cdata(),
self.filterSize:cdata(), self.filterSize:cdata(),
input.metadata.ffi, input.metadata.ffi,
...@@ -68,7 +68,7 @@ return function(sparseconvnet) ...@@ -68,7 +68,7 @@ return function(sparseconvnet)
end end
function Convolution:backward(input, gradOutput) function Convolution:backward(input, gradOutput)
C.dimTypedFn(self.dimension, self._type, 'ValidConvolution_backward')( C.dimTypedFn(self.dimension, self._type, 'SubmanifoldConvolution_backward')(
input.spatialSize:cdata(), input.spatialSize:cdata(),
self.filterSize:cdata(), self.filterSize:cdata(),
input.metadata.ffi, input.metadata.ffi,
...@@ -100,7 +100,7 @@ return function(sparseconvnet) ...@@ -100,7 +100,7 @@ return function(sparseconvnet)
end end
function Convolution:__tostring() function Convolution:__tostring()
local s = 'ValidConvolution ' .. self.nInputPlanes .. '->' .. self.nOutputPlanes..' C' local s = 'SubmanifoldConvolution ' .. self.nInputPlanes .. '->' .. self.nOutputPlanes..' C'
if self.filterSize:max()==self.filterSize:min() and if self.filterSize:max()==self.filterSize:min() and
self.filterStride:max()==self.filterStride:min() then self.filterStride:max()==self.filterStride:min() then
s=s..self.filterSize[1] ..(self.filterStride[1]==1 and s=s..self.filterSize[1] ..(self.filterStride[1]==1 and
......
...@@ -35,7 +35,7 @@ for _,module in ipairs({ ...@@ -35,7 +35,7 @@ for _,module in ipairs({
'sparseconvnet.ReLU', 'sparseconvnet.ReLU',
'sparseconvnet.Sequential', 'sparseconvnet.Sequential',
'sparseconvnet.SparseToDense', 'sparseconvnet.SparseToDense',
'sparseconvnet.ValidConvolution', 'sparseconvnet.SubmanifoldConvolution',
}) do }) do
require(module)(sparseconvnet) require(module)(sparseconvnet)
end end
......
...@@ -14,7 +14,7 @@ local sparseModel = sparseconvnet.Sequential() ...@@ -14,7 +14,7 @@ local sparseModel = sparseconvnet.Sequential()
local denseModel = nn.Sequential() local denseModel = nn.Sequential()
model:add(sparseModel):add(denseModel) model:add(sparseModel):add(denseModel)
sparseModel sparseModel
:add(sparseconvnet.ValidConvolution(2,3,16,3,false)) :add(sparseconvnet.SubmanifoldConvolution(2,3,16,3,false))
:add(sparseconvnet.SparseDenseNet(2,16,{ :add(sparseconvnet.SparseDenseNet(2,16,{
{'MP',compression=0}, {'MP',compression=0},
{nExtraLayers=2, growthRate=16}, {nExtraLayers=2, growthRate=16},
......
...@@ -17,7 +17,7 @@ model = nn.Sequential() ...@@ -17,7 +17,7 @@ model = nn.Sequential()
sparseModel = scn.Sequential() sparseModel = scn.Sequential()
denseModel = nn.Sequential() denseModel = nn.Sequential()
model.add(sparseModel).add(denseModel) model.add(sparseModel).add(denseModel)
sparseModel.add(scn.ValidConvolution(2, 3, 8, 3, False))\ sparseModel.add(scn.SubmanifoldConvolution(2, 3, 8, 3, False))\
.add(scn.SparseDenseNet(2, 8, [ .add(scn.SparseDenseNet(2, 8, [
{'pool': 'MP', 'compression': 0}, {'pool': 'MP', 'compression': 0},
{'nExtraLayers': 2, 'growthRate': 8}, {'nExtraLayers': 2, 'growthRate': 8},
......
...@@ -14,7 +14,7 @@ local sparseModel = sparseconvnet.Sequential() ...@@ -14,7 +14,7 @@ local sparseModel = sparseconvnet.Sequential()
local denseModel = nn.Sequential() local denseModel = nn.Sequential()
model:add(sparseModel):add(denseModel) model:add(sparseModel):add(denseModel)
sparseModel sparseModel
:add(sparseconvnet.ValidConvolution(2,3,8,3,false)) :add(sparseconvnet.SubmanifoldConvolution(2,3,8,3,false))
:add(sparseconvnet.MaxPooling(2,3,2)) :add(sparseconvnet.MaxPooling(2,3,2))
:add(sparseconvnet.SparseResNet( :add(sparseconvnet.SparseResNet(
2,8,{ 2,8,{
......
...@@ -10,11 +10,13 @@ import sparseconvnet as scn ...@@ -10,11 +10,13 @@ import sparseconvnet as scn
from data import getIterators from data import getIterators
# two-dimensional SparseConvNet # two-dimensional SparseConvNet
class Model(nn.Module): class Model(nn.Module):
def __init__(self): def __init__(self):
nn.Module.__init__(self) nn.Module.__init__(self)
self.sparseModel=scn.Sequential( self.sparseModel = scn.Sequential(
).add(scn.ValidConvolution(2, 3, 8, 3, False) ).add(scn.SubmanifoldConvolution(2, 3, 8, 3, False)
).add(scn.MaxPooling(2, 3, 2) ).add(scn.MaxPooling(2, 3, 2)
).add(scn.SparseResNet(2, 8, [ ).add(scn.SparseResNet(2, 8, [
['b', 8, 2, 1], ['b', 8, 2, 1],
...@@ -23,15 +25,17 @@ class Model(nn.Module): ...@@ -23,15 +25,17 @@ class Model(nn.Module):
['b', 32, 2, 2]]) ['b', 32, 2, 2]])
).add(scn.Convolution(2, 32, 64, 5, 1, False) ).add(scn.Convolution(2, 32, 64, 5, 1, False)
).add(scn.BatchNormReLU(64) ).add(scn.BatchNormReLU(64)
).add(scn.SparseToDense(2,64)) ).add(scn.SparseToDense(2, 64))
self.linear = nn.Linear(64, 183) self.linear = nn.Linear(64, 183)
def forward(self, x): def forward(self, x):
x = self.sparseModel(x) x = self.sparseModel(x)
x = x.view(-1,64) x = x.view(-1, 64)
x = self.linear(x) x = self.linear(x)
return x return x
model=Model()
model = Model()
spatial_size = model.sparseModel.input_spatial_size(torch.LongTensor([1, 1])) spatial_size = model.sparseModel.input_spatial_size(torch.LongTensor([1, 1]))
print('Input spatial size:', spatial_size) print('Input spatial size:', spatial_size)
dataset = getIterators(spatial_size, 63, 3) dataset = getIterators(spatial_size, 63, 3)
...@@ -42,4 +46,4 @@ scn.ClassificationTrainValidate( ...@@ -42,4 +46,4 @@ scn.ClassificationTrainValidate(
'lr_decay': 0.05, 'lr_decay': 0.05,
'weight_decay': 1e-4, 'weight_decay': 1e-4,
'use_gpu': torch.cuda.is_available(), 'use_gpu': torch.cuda.is_available(),
'check_point': True,}) 'check_point': True, })
...@@ -17,7 +17,7 @@ model = nn.Sequential() ...@@ -17,7 +17,7 @@ model = nn.Sequential()
sparseModel = scn.Sequential() sparseModel = scn.Sequential()
denseModel = nn.Sequential() denseModel = nn.Sequential()
model.add(sparseModel).add(denseModel) model.add(sparseModel).add(denseModel)
sparseModel.add(scn.ValidConvolution(2, 3, 8, 3, False)) sparseModel.add(scn.SubmanifoldConvolution(2, 3, 8, 3, False))
sparseModel.add(scn.MaxPooling(2, 3, 2)) sparseModel.add(scn.MaxPooling(2, 3, 2))
sparseModel.add(scn.SparseResNet(2, 8, [ sparseModel.add(scn.SparseResNet(2, 8, [
['b', 8, 2, 1], ['b', 8, 2, 1],
......
...@@ -16,19 +16,21 @@ class Model(nn.Module): ...@@ -16,19 +16,21 @@ class Model(nn.Module):
self.sparseModel = scn.SparseVggNet(2, 3, [ self.sparseModel = scn.SparseVggNet(2, 3, [
['C', 8, ], ['C', 8], 'MP', ['C', 8, ], ['C', 8], 'MP',
['C', 16], ['C', 16], 'MP', ['C', 16], ['C', 16], 'MP',
['C', 16, 8], ['C', 16, 8], 'MP', ['C', 16 + 8], ['C', 16 + 8], 'MP',
['C', 24, 8], ['C', 24, 8], 'MP'] ['C', 24 + 8], ['C', 24 + 8], 'MP']
).add(scn.Convolution(2, 32, 64, 5, 1, False) ).add(scn.Convolution(2, 32, 64, 5, 1, False)
).add(scn.BatchNormReLU(64) ).add(scn.BatchNormReLU(64)
).add(scn.SparseToDense(2,64)) ).add(scn.SparseToDense(2, 64))
self.linear = nn.Linear(64, 183) self.linear = nn.Linear(64, 183)
def forward(self, x): def forward(self, x):
x = self.sparseModel(x) x = self.sparseModel(x)
x = x.view(-1,64) x = x.view(-1, 64)
x = self.linear(x) x = self.linear(x)
return x return x
model=Model()
model = Model()
spatial_size = model.sparseModel.input_spatial_size(torch.LongTensor([1, 1])) spatial_size = model.sparseModel.input_spatial_size(torch.LongTensor([1, 1]))
print('Input spatial size:', spatial_size) print('Input spatial size:', spatial_size)
dataset = getIterators(spatial_size, 63, 3) dataset = getIterators(spatial_size, 63, 3)
...@@ -39,4 +41,4 @@ scn.ClassificationTrainValidate( ...@@ -39,4 +41,4 @@ scn.ClassificationTrainValidate(
'lr_decay': 0.05, 'lr_decay': 0.05,
'weight_decay': 1e-4, 'weight_decay': 1e-4,
'use_gpu': torch.cuda.is_available(), 'use_gpu': torch.cuda.is_available(),
'check_point': True,}) 'check_point': True, })
...@@ -33,6 +33,10 @@ print(model) ...@@ -33,6 +33,10 @@ print(model)
spatial_size = sparseModel.suggestInputSize(torch.LongTensor([1, 1])) spatial_size = sparseModel.suggestInputSize(torch.LongTensor([1, 1]))
print('input spatial size', spatial_size) print('input spatial size', spatial_size)
dataset = getIterators(spatial_size, 63, 3) dataset = getIterators(spatial_size, 63, 3)
scn.ClassificationTrainValidate( scn.ClassificationTrainValidate(model,
model, dataset, dataset,
{'nEpochs': 100, 'initial_LR': 0.1, 'LR_decay': 0.05, 'weightDecay': 1e-4, 'checkPoint': False}) {'nEpochs': 100,
'initial_LR': 0.1,
'LR_decay': 0.05,
'weightDecay': 1e-4,
'checkPoint': False})
...@@ -10,7 +10,7 @@ import sparseconvnet.legacy as scn ...@@ -10,7 +10,7 @@ import sparseconvnet.legacy as scn
import pickle import pickle
import math import math
import random import random
import numpy import numpy as np
import os import os
if not os.path.exists('pickle/'): if not os.path.exists('pickle/'):
...@@ -25,6 +25,8 @@ def train(spatial_size, Scale, precomputeStride): ...@@ -25,6 +25,8 @@ def train(spatial_size, Scale, precomputeStride):
for i in range(9): for i in range(9):
for j in range(6588): for j in range(6588):
d.append(d[j]) d.append(d[j])
for i, x in enumerate(d):
x['idx'] = i
d = torchnet.dataset.ListDataset(d) d = torchnet.dataset.ListDataset(d)
randperm = torch.randperm(len(d)) randperm = torch.randperm(len(d))
...@@ -36,10 +38,11 @@ def train(spatial_size, Scale, precomputeStride): ...@@ -36,10 +38,11 @@ def train(spatial_size, Scale, precomputeStride):
center = spatial_size.float().view(1, 2) / 2 center = spatial_size.float().view(1, 2) / 2
p = torch.LongTensor(2) p = torch.LongTensor(2)
v = torch.FloatTensor([1, 0, 0]) v = torch.FloatTensor([1, 0, 0])
np_random = np.random.RandomState(tbl['idx'])
for char in tbl['input']: for char in tbl['input']:
inp.addSample() inp.addSample()
m = torch.eye(2) m = torch.eye(2)
r = random.randint(1, 3) r = np_random.randint(1, 3)
alpha = random.uniform(-0.2, 0.2) alpha = random.uniform(-0.2, 0.2)
if alpha == 1: if alpha == 1:
m[0][1] = alpha m[0][1] = alpha
...@@ -74,7 +77,7 @@ def train(spatial_size, Scale, precomputeStride): ...@@ -74,7 +77,7 @@ def train(spatial_size, Scale, precomputeStride):
# v[1]=(x2-x1)/l # v[1]=(x2-x1)/l
# v[2]=(y2-y1)/l # v[2]=(y2-y1)/l
# l=max(x2-x1,y2-y1,x1-x2,y1-y2,0.9) # l=max(x2-x1,y2-y1,x1-x2,y1-y2,0.9)
# for j in numpy.arange(0,1,1/l): # for j in np.arange(0,1,1/l):
# p[0]=math.floor(x1*j+x2*(1-j)) # p[0]=math.floor(x1*j+x2*(1-j))
# p[1]=math.floor(y1*j+y2*(1-j)) # p[1]=math.floor(y1*j+y2*(1-j))
# inp.setLocation(p,v,False) # inp.setLocation(p,v,False)
......
...@@ -14,7 +14,7 @@ local denseModel = nn.Sequential() ...@@ -14,7 +14,7 @@ local denseModel = nn.Sequential()
local model = nn.Sequential():add(sparseModel):add(denseModel) local model = nn.Sequential():add(sparseModel):add(denseModel)
sparseModel sparseModel
:add(sparseconvnet.ValidConvolution(2,3,16,3,false)) :add(sparseconvnet.SubmanifoldConvolution(2,3,16,3,false))
:add(sparseconvnet.SparseDenseNet(2,16,{ :add(sparseconvnet.SparseDenseNet(2,16,{
{'MP',compression=0}, {'MP',compression=0},
{nExtraLayers=2, growthRate=16}, {nExtraLayers=2, growthRate=16},
......
...@@ -17,7 +17,7 @@ model = nn.Sequential() ...@@ -17,7 +17,7 @@ model = nn.Sequential()
sparseModel = scn.Sequential() sparseModel = scn.Sequential()
denseModel = nn.Sequential() denseModel = nn.Sequential()
model.add(sparseModel).add(denseModel) model.add(sparseModel).add(denseModel)
sparseModel.add(scn.ValidConvolution(2, 3, 16, 3, False))\ sparseModel.add(scn.SubmanifoldConvolution(2, 3, 16, 3, False))\
.add(scn.SparseDenseNet(2, 16, [ .add(scn.SparseDenseNet(2, 16, [
{'pool': 'MP', 'compression': 0}, {'pool': 'MP', 'compression': 0},
{'nExtraLayers': 2, 'growthRate': 16}, {'nExtraLayers': 2, 'growthRate': 16},
......
...@@ -14,7 +14,7 @@ local denseModel = nn.Sequential() ...@@ -14,7 +14,7 @@ local denseModel = nn.Sequential()
local model = nn.Sequential():add(sparseModel):add(denseModel) local model = nn.Sequential():add(sparseModel):add(denseModel)
sparseModel sparseModel
:add(sparseconvnet.ValidConvolution(2,3,16,3,false)) :add(sparseconvnet.SubmanifoldConvolution(2,3,16,3,false))
:add(sparseconvnet.SparseDenseNet(2,16,{ :add(sparseconvnet.SparseDenseNet(2,16,{
{'MP',compression=0}, {'MP',compression=0},
{nExtraLayers=4, growthRate=16}, {nExtraLayers=4, growthRate=16},
......
...@@ -24,7 +24,7 @@ local denseModel = nn.Sequential() ...@@ -24,7 +24,7 @@ local denseModel = nn.Sequential()
local model = nn.Sequential():add(sparseModel):add(denseModel) local model = nn.Sequential():add(sparseModel):add(denseModel)
sparseModel sparseModel
:add(sparseconvnet.ValidConvolution(2,3,16,3,false)) :add(sparseconvnet.SubmanifoldConvolution(2,3,16,3,false))
:add(sparseconvnet.MaxPooling(2,2,2)) :add(sparseconvnet.MaxPooling(2,2,2))
:add(sparseconvnet.SparseResNet( :add(sparseconvnet.SparseResNet(
2,16,{ 2,16,{
......
...@@ -17,7 +17,7 @@ model = nn.Sequential() ...@@ -17,7 +17,7 @@ model = nn.Sequential()
sparseModel = scn.Sequential() sparseModel = scn.Sequential()
denseModel = nn.Sequential() denseModel = nn.Sequential()
model.add(sparseModel).add(denseModel) model.add(sparseModel).add(denseModel)
sparseModel.add(scn.ValidConvolution(2, 3, 16, 3, False)) sparseModel.add(scn.SubmanifoldConvolution(2, 3, 16, 3, False))
sparseModel.add(scn.MaxPooling(2, 3, 2)) sparseModel.add(scn.MaxPooling(2, 3, 2))
sparseModel.add(scn.SparseResNet(2, 16, [ sparseModel.add(scn.SparseResNet(2, 16, [
['b', 16, 2, 1], ['b', 16, 2, 1],
......
...@@ -14,7 +14,7 @@ local denseModel = nn.Sequential() ...@@ -14,7 +14,7 @@ local denseModel = nn.Sequential()
local model = nn.Sequential():add(sparseModel):add(denseModel) local model = nn.Sequential():add(sparseModel):add(denseModel)
sparseModel sparseModel
:add(sparseconvnet.ValidConvolution(2,3,16,3,false)) :add(sparseconvnet.SubmanifoldConvolution(2,3,16,3,false))
:add(sparseconvnet.MaxPooling(2,2,2)) :add(sparseconvnet.MaxPooling(2,2,2))
:add(sparseconvnet.SparseResNet( :add(sparseconvnet.SparseResNet(
2,16,{ 2,16,{
......
...@@ -24,7 +24,7 @@ local denseModel = nn.Sequential() ...@@ -24,7 +24,7 @@ local denseModel = nn.Sequential()
local model = nn.Sequential():add(sparseModel):add(denseModel) local model = nn.Sequential():add(sparseModel):add(denseModel)
sparseModel sparseModel
:add(sparseconvnet.ValidConvolution(2,3,16,3,false)) :add(sparseconvnet.SubmanifoldConvolution(2,3,16,3,false))
:add(sparseconvnet.MaxPooling(2,2,2)) :add(sparseconvnet.MaxPooling(2,2,2))
:add(sparseconvnet.SparseResNet( :add(sparseconvnet.SparseResNet(
2,16,{ 2,16,{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment