Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CNNArch2Caffe2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
monticore
EmbeddedMontiArc
generators
CNNArch2Caffe2
Commits
e6d2739f
Commit
e6d2739f
authored
Nov 08, 2018
by
Carlos Alfredo Yeverino Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrected target code for testing according to the fix.
parent
e37882d3
Pipeline
#83442
failed with stages
in 4 minutes and 16 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
39 deletions
+39
-39
src/test/resources/target_code/CNNCreator_Alexnet.py
src/test/resources/target_code/CNNCreator_Alexnet.py
+13
-13
src/test/resources/target_code/CNNCreator_CifarClassifierNetwork.py
...esources/target_code/CNNCreator_CifarClassifierNetwork.py
+13
-13
src/test/resources/target_code/CNNCreator_VGG16.py
src/test/resources/target_code/CNNCreator_VGG16.py
+13
-13
No files found.
src/test/resources/target_code/CNNCreator_Alexnet.py
View file @
e6d2739f
...
...
@@ -5,7 +5,7 @@ import numpy as np
import
logging
import
os
import
sys
import
lmdb
class
CNNCreator_Alexnet
:
module
=
None
...
...
@@ -34,7 +34,10 @@ class CNNCreator_Alexnet:
# don't need the gradient for the backward pass
data
=
model
.
StopGradient
(
data
,
data
)
return
data
,
label
dataset_size
=
int
(
lmdb
.
open
(
db
).
stat
()[
'entries'
])
return
data
,
label
,
dataset_size
def
create_model
(
self
,
model
,
data
,
device_opts
):
with
core
.
DeviceScope
(
device_opts
):
...
...
@@ -187,7 +190,7 @@ class CNNCreator_Alexnet:
arg_scope
=
{
"order"
:
"NCHW"
}
# == Training model ==
train_model
=
model_helper
.
ModelHelper
(
name
=
"train_net"
,
arg_scope
=
arg_scope
)
data
,
label
=
self
.
add_input
(
train_model
,
batch_size
=
batch_size
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-train-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
data
,
label
,
train_dataset_size
=
self
.
add_input
(
train_model
,
batch_size
=
batch_size
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-train-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
predictions
=
self
.
create_model
(
train_model
,
data
,
device_opts
=
device_opts
)
self
.
add_training_operators
(
train_model
,
predictions
,
label
,
device_opts
,
opt_type
,
base_learning_rate
,
policy
,
stepsize
,
epsilon
,
beta1
,
beta2
,
gamma
,
momentum
)
self
.
add_accuracy
(
train_model
,
predictions
,
label
,
device_opts
,
eval_metric
)
...
...
@@ -199,28 +202,25 @@ class CNNCreator_Alexnet:
workspace
.
CreateNet
(
train_model
.
net
,
overwrite
=
True
)
# Main Training Loop
print
(
"== Starting Training for "
+
str
(
num_epoch
)
+
"
num_epoch
=="
)
for
j
in
range
(
0
,
num_epoch
):
print
(
"== Starting Training for "
+
str
(
num_epoch
)
+
"
epochs
=="
)
for
i
in
range
(
num_epoch
):
workspace
.
RunNet
(
train_model
.
net
)
if
j
%
50
==
0
:
print
'Iter
: '
+
str
(
j
)
+
': '
+
'Loss '
+
str
(
workspace
.
FetchBlob
(
"loss"
))
+
' - '
+
'Accuracy '
+
str
(
workspace
.
FetchBlob
(
'accuracy'
))
if
i
%
50
==
0
:
print
'Iter
'
+
str
(
i
)
+
': '
+
'Loss '
+
str
(
workspace
.
FetchBlob
(
"loss"
))
+
' - '
+
'Accuracy '
+
str
(
workspace
.
FetchBlob
(
'accuracy'
))
print
(
"Training done"
)
print
(
"== Running Test model =="
)
# == Testing model. ==
test_model
=
model_helper
.
ModelHelper
(
name
=
"test_net"
,
arg_scope
=
arg_scope
,
init_params
=
False
)
data
,
label
=
self
.
add_input
(
test_model
,
batch_size
=
100
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-test-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
data
,
label
,
test_dataset_size
=
self
.
add_input
(
test_model
,
batch_size
=
batch_size
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-test-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
predictions
=
self
.
create_model
(
test_model
,
data
,
device_opts
=
device_opts
)
self
.
add_accuracy
(
test_model
,
predictions
,
label
,
device_opts
,
eval_metric
)
workspace
.
RunNetOnce
(
test_model
.
param_init_net
)
workspace
.
CreateNet
(
test_model
.
net
,
overwrite
=
True
)
# Main Testing Loop
# batch size: 100
# iteration: 100
# total test images: 10000
test_accuracy
=
np
.
zeros
(
100
)
for
i
in
range
(
100
):
test_accuracy
=
np
.
zeros
(
test_dataset_size
/
batch_size
)
for
i
in
range
(
test_dataset_size
/
batch_size
):
# Run a forward pass of the net on the current batch
workspace
.
RunNet
(
test_model
.
net
)
# Collect the batch accuracy from the workspace
...
...
src/test/resources/target_code/CNNCreator_CifarClassifierNetwork.py
View file @
e6d2739f
...
...
@@ -5,7 +5,7 @@ import numpy as np
import
logging
import
os
import
sys
import
lmdb
class
CNNCreator_CifarClassifierNetwork
:
module
=
None
...
...
@@ -34,7 +34,10 @@ class CNNCreator_CifarClassifierNetwork:
# don't need the gradient for the backward pass
data
=
model
.
StopGradient
(
data
,
data
)
return
data
,
label
dataset_size
=
int
(
lmdb
.
open
(
db
).
stat
()[
'entries'
])
return
data
,
label
,
dataset_size
def
create_model
(
self
,
model
,
data
,
device_opts
):
with
core
.
DeviceScope
(
device_opts
):
...
...
@@ -272,7 +275,7 @@ class CNNCreator_CifarClassifierNetwork:
arg_scope
=
{
"order"
:
"NCHW"
}
# == Training model ==
train_model
=
model_helper
.
ModelHelper
(
name
=
"train_net"
,
arg_scope
=
arg_scope
)
data
,
label
=
self
.
add_input
(
train_model
,
batch_size
=
batch_size
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-train-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
data
,
label
,
train_dataset_size
=
self
.
add_input
(
train_model
,
batch_size
=
batch_size
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-train-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
softmax
=
self
.
create_model
(
train_model
,
data
,
device_opts
=
device_opts
)
self
.
add_training_operators
(
train_model
,
softmax
,
label
,
device_opts
,
opt_type
,
base_learning_rate
,
policy
,
stepsize
,
epsilon
,
beta1
,
beta2
,
gamma
,
momentum
)
self
.
add_accuracy
(
train_model
,
softmax
,
label
,
device_opts
,
eval_metric
)
...
...
@@ -284,28 +287,25 @@ class CNNCreator_CifarClassifierNetwork:
workspace
.
CreateNet
(
train_model
.
net
,
overwrite
=
True
)
# Main Training Loop
print
(
"== Starting Training for "
+
str
(
num_epoch
)
+
"
num_epoch
=="
)
for
j
in
range
(
0
,
num_epoch
):
print
(
"== Starting Training for "
+
str
(
num_epoch
)
+
"
epochs
=="
)
for
i
in
range
(
num_epoch
):
workspace
.
RunNet
(
train_model
.
net
)
if
j
%
50
==
0
:
print
'Iter
: '
+
str
(
j
)
+
': '
+
'Loss '
+
str
(
workspace
.
FetchBlob
(
"loss"
))
+
' - '
+
'Accuracy '
+
str
(
workspace
.
FetchBlob
(
'accuracy'
))
if
i
%
50
==
0
:
print
'Iter
'
+
str
(
i
)
+
': '
+
'Loss '
+
str
(
workspace
.
FetchBlob
(
"loss"
))
+
' - '
+
'Accuracy '
+
str
(
workspace
.
FetchBlob
(
'accuracy'
))
print
(
"Training done"
)
print
(
"== Running Test model =="
)
# == Testing model. ==
test_model
=
model_helper
.
ModelHelper
(
name
=
"test_net"
,
arg_scope
=
arg_scope
,
init_params
=
False
)
data
,
label
=
self
.
add_input
(
test_model
,
batch_size
=
100
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-test-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
data
,
label
,
test_dataset_size
=
self
.
add_input
(
test_model
,
batch_size
=
batch_size
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-test-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
softmax
=
self
.
create_model
(
test_model
,
data
,
device_opts
=
device_opts
)
self
.
add_accuracy
(
test_model
,
predictions
,
label
,
device_opts
,
eval_metric
)
workspace
.
RunNetOnce
(
test_model
.
param_init_net
)
workspace
.
CreateNet
(
test_model
.
net
,
overwrite
=
True
)
# Main Testing Loop
# batch size: 100
# iteration: 100
# total test images: 10000
test_accuracy
=
np
.
zeros
(
100
)
for
i
in
range
(
100
):
test_accuracy
=
np
.
zeros
(
test_dataset_size
/
batch_size
)
for
i
in
range
(
test_dataset_size
/
batch_size
):
# Run a forward pass of the net on the current batch
workspace
.
RunNet
(
test_model
.
net
)
# Collect the batch accuracy from the workspace
...
...
src/test/resources/target_code/CNNCreator_VGG16.py
View file @
e6d2739f
...
...
@@ -5,7 +5,7 @@ import numpy as np
import
logging
import
os
import
sys
import
lmdb
class
CNNCreator_VGG16
:
module
=
None
...
...
@@ -34,7 +34,10 @@ class CNNCreator_VGG16:
# don't need the gradient for the backward pass
data
=
model
.
StopGradient
(
data
,
data
)
return
data
,
label
dataset_size
=
int
(
lmdb
.
open
(
db
).
stat
()[
'entries'
])
return
data
,
label
,
dataset_size
def
create_model
(
self
,
model
,
data
,
device_opts
):
with
core
.
DeviceScope
(
device_opts
):
...
...
@@ -162,7 +165,7 @@ class CNNCreator_VGG16:
arg_scope
=
{
"order"
:
"NCHW"
}
# == Training model ==
train_model
=
model_helper
.
ModelHelper
(
name
=
"train_net"
,
arg_scope
=
arg_scope
)
data
,
label
=
self
.
add_input
(
train_model
,
batch_size
=
batch_size
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-train-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
data
,
label
,
train_dataset_size
=
self
.
add_input
(
train_model
,
batch_size
=
batch_size
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-train-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
predictions
=
self
.
create_model
(
train_model
,
data
,
device_opts
=
device_opts
)
self
.
add_training_operators
(
train_model
,
predictions
,
label
,
device_opts
,
opt_type
,
base_learning_rate
,
policy
,
stepsize
,
epsilon
,
beta1
,
beta2
,
gamma
,
momentum
)
self
.
add_accuracy
(
train_model
,
predictions
,
label
,
device_opts
,
eval_metric
)
...
...
@@ -174,28 +177,25 @@ class CNNCreator_VGG16:
workspace
.
CreateNet
(
train_model
.
net
,
overwrite
=
True
)
# Main Training Loop
print
(
"== Starting Training for "
+
str
(
num_epoch
)
+
"
num_epoch
=="
)
for
j
in
range
(
0
,
num_epoch
):
print
(
"== Starting Training for "
+
str
(
num_epoch
)
+
"
epochs
=="
)
for
i
in
range
(
num_epoch
):
workspace
.
RunNet
(
train_model
.
net
)
if
j
%
50
==
0
:
print
'Iter
: '
+
str
(
j
)
+
': '
+
'Loss '
+
str
(
workspace
.
FetchBlob
(
"loss"
))
+
' - '
+
'Accuracy '
+
str
(
workspace
.
FetchBlob
(
'accuracy'
))
if
i
%
50
==
0
:
print
'Iter
'
+
str
(
i
)
+
': '
+
'Loss '
+
str
(
workspace
.
FetchBlob
(
"loss"
))
+
' - '
+
'Accuracy '
+
str
(
workspace
.
FetchBlob
(
'accuracy'
))
print
(
"Training done"
)
print
(
"== Running Test model =="
)
# == Testing model. ==
test_model
=
model_helper
.
ModelHelper
(
name
=
"test_net"
,
arg_scope
=
arg_scope
,
init_params
=
False
)
data
,
label
=
self
.
add_input
(
test_model
,
batch_size
=
100
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-test-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
data
,
label
,
test_dataset_size
=
self
.
add_input
(
test_model
,
batch_size
=
batch_size
,
db
=
os
.
path
.
join
(
self
.
_data_dir_
,
'mnist-test-nchw-lmdb'
),
db_type
=
'lmdb'
,
device_opts
=
device_opts
)
predictions
=
self
.
create_model
(
test_model
,
data
,
device_opts
=
device_opts
)
self
.
add_accuracy
(
test_model
,
predictions
,
label
,
device_opts
,
eval_metric
)
workspace
.
RunNetOnce
(
test_model
.
param_init_net
)
workspace
.
CreateNet
(
test_model
.
net
,
overwrite
=
True
)
# Main Testing Loop
# batch size: 100
# iteration: 100
# total test images: 10000
test_accuracy
=
np
.
zeros
(
100
)
for
i
in
range
(
100
):
test_accuracy
=
np
.
zeros
(
test_dataset_size
/
batch_size
)
for
i
in
range
(
test_dataset_size
/
batch_size
):
# Run a forward pass of the net on the current batch
workspace
.
RunNet
(
test_model
.
net
)
# Collect the batch accuracy from the workspace
...
...
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