Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
SparseConvNet
Commits
13bdf051
Commit
13bdf051
authored
Nov 17, 2017
by
Benjamin Thomas Graham
Browse files
Use Height x Width notation in hello world examples
parent
71f496e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
21 deletions
+21
-21
examples/hello-world.lua
examples/hello-world.lua
+11
-11
examples/hello-world.py
examples/hello-world.py
+10
-10
No files found.
examples/hello-world.lua
View file @
13bdf051
...
@@ -11,15 +11,15 @@ tensorType = scn.cutorch and 'torch.CudaTensor' or 'torch.FloatTensor'
...
@@ -11,15 +11,15 @@ tensorType = scn.cutorch and 'torch.CudaTensor' or 'torch.FloatTensor'
model
=
scn
.
Sequential
()
model
=
scn
.
Sequential
()
:
add
(
scn
.
SparseVggNet
(
2
,
1
,{
--dimension 2, 1 input plane
:
add
(
scn
.
SparseVggNet
(
2
,
1
,{
--dimension 2, 1 input plane
{
'C'
,
8
},
-- 3x3 VSC convolution, 8 output planes, batchnorm, ReLU
{
'C'
,
8
},
-- 3x3 VSC convolution, 8 output planes, batchnorm, ReLU
{
'C'
,
8
},
-- and another
{
'C'
,
8
},
-- and another
{
'MP'
,
3
,
2
},
--max pooling, size 3, stride 2
{
'MP'
,
3
,
2
},
--max pooling, size 3, stride 2
{
'C'
,
16
},
-- etc
{
'C'
,
16
},
-- etc
{
'C'
,
16
},
{
'C'
,
16
},
{
'MP'
,
3
,
2
},
{
'MP'
,
3
,
2
},
{
'C'
,
24
},
{
'C'
,
24
},
{
'C'
,
24
},
{
'C'
,
24
},
{
'MP'
,
3
,
2
}}))
{
'MP'
,
3
,
2
}}))
:
add
(
scn
.
Convolution
(
2
,
24
,
32
,
3
,
1
,
false
))
--an SC convolution on top
:
add
(
scn
.
Convolution
(
2
,
24
,
32
,
3
,
1
,
false
))
--an SC convolution on top
:
add
(
scn
.
BatchNormReLU
(
32
))
:
add
(
scn
.
BatchNormReLU
(
32
))
:
add
(
scn
.
SparseToDense
(
2
))
:
add
(
scn
.
SparseToDense
(
2
))
...
@@ -47,7 +47,7 @@ input:addSample()
...
@@ -47,7 +47,7 @@ input:addSample()
for
y
,
line
in
ipairs
(
msg
)
do
for
y
,
line
in
ipairs
(
msg
)
do
for
x
=
1
,
string.len
(
line
)
do
for
x
=
1
,
string.len
(
line
)
do
if
string.sub
(
line
,
x
,
x
)
==
'O'
then
if
string.sub
(
line
,
x
,
x
)
==
'O'
then
local
location
=
torch
.
LongTensor
{
x
,
y
}
local
location
=
torch
.
LongTensor
{
y
,
x
}
local
featureVector
=
torch
.
FloatTensor
{
1
}
local
featureVector
=
torch
.
FloatTensor
{
1
}
input
:
setLocation
(
location
,
featureVector
,
0
)
input
:
setLocation
(
location
,
featureVector
,
0
)
end
end
...
@@ -61,7 +61,7 @@ local featureVectors = {}
...
@@ -61,7 +61,7 @@ local featureVectors = {}
for
y
,
line
in
ipairs
(
msg
)
do
for
y
,
line
in
ipairs
(
msg
)
do
for
x
=
1
,
string.len
(
line
)
do
for
x
=
1
,
string.len
(
line
)
do
if
string.sub
(
line
,
x
,
x
)
==
'O'
then
if
string.sub
(
line
,
x
,
x
)
==
'O'
then
table.insert
(
locations
,
{
x
,
y
})
table.insert
(
locations
,
{
y
,
x
})
table.insert
(
featureVectors
,
{
1
})
table.insert
(
featureVectors
,
{
1
})
end
end
end
end
...
...
examples/hello-world.py
View file @
13bdf051
...
@@ -12,9 +12,9 @@ use_gpu = torch.cuda.is_available()
...
@@ -12,9 +12,9 @@ use_gpu = torch.cuda.is_available()
model
=
scn
.
Sequential
().
add
(
model
=
scn
.
Sequential
().
add
(
scn
.
SparseVggNet
(
2
,
1
,
scn
.
SparseVggNet
(
2
,
1
,
[[
'C'
,
8
],
[
'C'
,
8
],
[
'MP'
,
3
,
2
],
[[
'C'
,
8
],
[
'C'
,
8
],
[
'MP'
,
3
,
2
],
[
'C'
,
16
],
[
'C'
,
16
],
[
'MP'
,
3
,
2
],
[
'C'
,
16
],
[
'C'
,
16
],
[
'MP'
,
3
,
2
],
[
'C'
,
24
],
[
'C'
,
24
],
[
'MP'
,
3
,
2
]])
[
'C'
,
24
],
[
'C'
,
24
],
[
'MP'
,
3
,
2
]])
).
add
(
).
add
(
scn
.
ValidConvolution
(
2
,
24
,
32
,
3
,
False
)
scn
.
ValidConvolution
(
2
,
24
,
32
,
3
,
False
)
).
add
(
).
add
(
...
@@ -40,10 +40,10 @@ msg = [
...
@@ -40,10 +40,10 @@ msg = [
input
.
addSample
()
input
.
addSample
()
for
y
,
line
in
enumerate
(
msg
):
for
y
,
line
in
enumerate
(
msg
):
for
x
,
c
in
enumerate
(
line
):
for
x
,
c
in
enumerate
(
line
):
if
c
==
'X'
:
if
c
==
'X'
:
location
=
torch
.
LongTensor
([
x
,
y
])
location
=
torch
.
LongTensor
([
y
,
x
])
featureVector
=
torch
.
FloatTensor
([
1
])
featureVector
=
torch
.
FloatTensor
([
1
])
input
.
setLocation
(
location
,
featureVector
,
0
)
input
.
setLocation
(
location
,
featureVector
,
0
)
#Add a sample using setLocations
#Add a sample using setLocations
input
.
addSample
()
input
.
addSample
()
...
@@ -51,9 +51,9 @@ locations = []
...
@@ -51,9 +51,9 @@ locations = []
features
=
[]
features
=
[]
for
y
,
line
in
enumerate
(
msg
):
for
y
,
line
in
enumerate
(
msg
):
for
x
,
c
in
enumerate
(
line
):
for
x
,
c
in
enumerate
(
line
):
if
c
==
'X'
:
if
c
==
'X'
:
locations
.
append
([
x
,
y
])
locations
.
append
([
y
,
x
])
features
.
append
([
1
])
features
.
append
([
1
])
locations
=
torch
.
LongTensor
(
locations
)
locations
=
torch
.
LongTensor
(
locations
)
features
=
torch
.
FloatTensor
(
features
)
features
=
torch
.
FloatTensor
(
features
)
input
.
setLocations
(
locations
,
features
,
0
)
input
.
setLocations
(
locations
,
features
,
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment