Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
monticore
EmbeddedMontiArc
generators
CNNArch2Gluon
Commits
87aff72b
Commit
87aff72b
authored
Nov 12, 2019
by
Christian Fuß
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed small bug in bleu computation
parent
a67329e1
Pipeline
#205603
failed with stages
in 19 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
15 deletions
+18
-15
src/test/resources/target_code/CNNSupervisedTrainer_Alexnet.py
...est/resources/target_code/CNNSupervisedTrainer_Alexnet.py
+6
-5
src/test/resources/target_code/CNNSupervisedTrainer_CifarClassifierNetwork.py
...arget_code/CNNSupervisedTrainer_CifarClassifierNetwork.py
+6
-5
src/test/resources/target_code/CNNSupervisedTrainer_VGG16.py
src/test/resources/target_code/CNNSupervisedTrainer_VGG16.py
+6
-5
No files found.
src/test/resources/target_code/CNNSupervisedTrainer_Alexnet.py
View file @
87aff72b
...
...
@@ -115,7 +115,8 @@ class BLEU(mx.metric.EvalMetric):
i
*=
2
match_counts
=
1
/
i
precisions
[
n
]
=
match_counts
/
counts
if
(
match_counts
/
counts
)
>
0
:
precisions
[
n
]
=
match_counts
/
counts
bleu
=
self
.
_get_brevity_penalty
()
*
math
.
exp
(
sum
(
map
(
math
.
log
,
precisions
))
/
self
.
N
)
...
...
@@ -320,7 +321,7 @@ class CNNSupervisedTrainer_Alexnet:
train_test_iter
.
reset
()
metric
=
mx
.
metric
.
create
(
eval_metric
,
**
eval_metric_params
)
for
batch_i
,
batch
in
enumerate
(
train_test_iter
):
if
True
:
if
True
:
labels
=
[
batch
.
label
[
i
].
as_in_context
(
mx_context
)
for
i
in
range
(
1
)]
data_
=
batch
.
data
[
0
].
as_in_context
(
mx_context
)
...
...
@@ -354,7 +355,7 @@ class CNNSupervisedTrainer_Alexnet:
attention_resized
=
np
.
resize
(
attention
.
asnumpy
(),
(
8
,
8
))
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
l
+
1
)
ax
.
set_title
(
dict
[
int
(
labels
[
l
+
1
][
0
].
asscalar
())])
img
=
ax
.
imshow
(
train_images
[
0
+
test_batch_size
*
(
batch_i
)])
img
=
ax
.
imshow
(
train_images
[
0
+
test_batch_size
*
(
batch_i
)]
.
transpose
(
1
,
2
,
0
)
)
ax
.
imshow
(
attention_resized
,
cmap
=
'gray'
,
alpha
=
0.6
,
extent
=
img
.
get_extent
())
...
...
@@ -378,7 +379,7 @@ class CNNSupervisedTrainer_Alexnet:
test_iter
.
reset
()
metric
=
mx
.
metric
.
create
(
eval_metric
,
**
eval_metric_params
)
for
batch_i
,
batch
in
enumerate
(
test_iter
):
if
True
:
if
True
:
labels
=
[
batch
.
label
[
i
].
as_in_context
(
mx_context
)
for
i
in
range
(
1
)]
data_
=
batch
.
data
[
0
].
as_in_context
(
mx_context
)
...
...
@@ -406,7 +407,7 @@ class CNNSupervisedTrainer_Alexnet:
attention_resized
=
np
.
resize
(
attention
.
asnumpy
(),
(
8
,
8
))
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
l
+
1
)
ax
.
set_title
(
dict
[
int
(
mx
.
nd
.
slice_axis
(
mx
.
nd
.
argmax
(
outputs
[
l
+
1
],
axis
=
1
),
axis
=
0
,
begin
=
0
,
end
=
1
).
asscalar
())])
img
=
ax
.
imshow
(
test_images
[
0
+
test_batch_size
*
(
batch_i
)])
img
=
ax
.
imshow
(
test_images
[
0
+
test_batch_size
*
(
batch_i
)]
.
transpose
(
1
,
2
,
0
)
)
ax
.
imshow
(
attention_resized
,
cmap
=
'gray'
,
alpha
=
0.6
,
extent
=
img
.
get_extent
())
...
...
src/test/resources/target_code/CNNSupervisedTrainer_CifarClassifierNetwork.py
View file @
87aff72b
...
...
@@ -115,7 +115,8 @@ class BLEU(mx.metric.EvalMetric):
i
*=
2
match_counts
=
1
/
i
precisions
[
n
]
=
match_counts
/
counts
if
(
match_counts
/
counts
)
>
0
:
precisions
[
n
]
=
match_counts
/
counts
bleu
=
self
.
_get_brevity_penalty
()
*
math
.
exp
(
sum
(
map
(
math
.
log
,
precisions
))
/
self
.
N
)
...
...
@@ -320,7 +321,7 @@ class CNNSupervisedTrainer_CifarClassifierNetwork:
train_test_iter
.
reset
()
metric
=
mx
.
metric
.
create
(
eval_metric
,
**
eval_metric_params
)
for
batch_i
,
batch
in
enumerate
(
train_test_iter
):
if
True
:
if
True
:
labels
=
[
batch
.
label
[
i
].
as_in_context
(
mx_context
)
for
i
in
range
(
1
)]
data_
=
batch
.
data
[
0
].
as_in_context
(
mx_context
)
...
...
@@ -354,7 +355,7 @@ class CNNSupervisedTrainer_CifarClassifierNetwork:
attention_resized
=
np
.
resize
(
attention
.
asnumpy
(),
(
8
,
8
))
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
l
+
1
)
ax
.
set_title
(
dict
[
int
(
labels
[
l
+
1
][
0
].
asscalar
())])
img
=
ax
.
imshow
(
train_images
[
0
+
test_batch_size
*
(
batch_i
)])
img
=
ax
.
imshow
(
train_images
[
0
+
test_batch_size
*
(
batch_i
)]
.
transpose
(
1
,
2
,
0
)
)
ax
.
imshow
(
attention_resized
,
cmap
=
'gray'
,
alpha
=
0.6
,
extent
=
img
.
get_extent
())
...
...
@@ -378,7 +379,7 @@ class CNNSupervisedTrainer_CifarClassifierNetwork:
test_iter
.
reset
()
metric
=
mx
.
metric
.
create
(
eval_metric
,
**
eval_metric_params
)
for
batch_i
,
batch
in
enumerate
(
test_iter
):
if
True
:
if
True
:
labels
=
[
batch
.
label
[
i
].
as_in_context
(
mx_context
)
for
i
in
range
(
1
)]
data_
=
batch
.
data
[
0
].
as_in_context
(
mx_context
)
...
...
@@ -406,7 +407,7 @@ class CNNSupervisedTrainer_CifarClassifierNetwork:
attention_resized
=
np
.
resize
(
attention
.
asnumpy
(),
(
8
,
8
))
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
l
+
1
)
ax
.
set_title
(
dict
[
int
(
mx
.
nd
.
slice_axis
(
mx
.
nd
.
argmax
(
outputs
[
l
+
1
],
axis
=
1
),
axis
=
0
,
begin
=
0
,
end
=
1
).
asscalar
())])
img
=
ax
.
imshow
(
test_images
[
0
+
test_batch_size
*
(
batch_i
)])
img
=
ax
.
imshow
(
test_images
[
0
+
test_batch_size
*
(
batch_i
)]
.
transpose
(
1
,
2
,
0
)
)
ax
.
imshow
(
attention_resized
,
cmap
=
'gray'
,
alpha
=
0.6
,
extent
=
img
.
get_extent
())
...
...
src/test/resources/target_code/CNNSupervisedTrainer_VGG16.py
View file @
87aff72b
...
...
@@ -115,7 +115,8 @@ class BLEU(mx.metric.EvalMetric):
i
*=
2
match_counts
=
1
/
i
precisions
[
n
]
=
match_counts
/
counts
if
(
match_counts
/
counts
)
>
0
:
precisions
[
n
]
=
match_counts
/
counts
bleu
=
self
.
_get_brevity_penalty
()
*
math
.
exp
(
sum
(
map
(
math
.
log
,
precisions
))
/
self
.
N
)
...
...
@@ -320,7 +321,7 @@ class CNNSupervisedTrainer_VGG16:
train_test_iter
.
reset
()
metric
=
mx
.
metric
.
create
(
eval_metric
,
**
eval_metric_params
)
for
batch_i
,
batch
in
enumerate
(
train_test_iter
):
if
True
:
if
True
:
labels
=
[
batch
.
label
[
i
].
as_in_context
(
mx_context
)
for
i
in
range
(
1
)]
data_
=
batch
.
data
[
0
].
as_in_context
(
mx_context
)
...
...
@@ -354,7 +355,7 @@ class CNNSupervisedTrainer_VGG16:
attention_resized
=
np
.
resize
(
attention
.
asnumpy
(),
(
8
,
8
))
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
l
+
1
)
ax
.
set_title
(
dict
[
int
(
labels
[
l
+
1
][
0
].
asscalar
())])
img
=
ax
.
imshow
(
train_images
[
0
+
test_batch_size
*
(
batch_i
)])
img
=
ax
.
imshow
(
train_images
[
0
+
test_batch_size
*
(
batch_i
)]
.
transpose
(
1
,
2
,
0
)
)
ax
.
imshow
(
attention_resized
,
cmap
=
'gray'
,
alpha
=
0.6
,
extent
=
img
.
get_extent
())
...
...
@@ -378,7 +379,7 @@ class CNNSupervisedTrainer_VGG16:
test_iter
.
reset
()
metric
=
mx
.
metric
.
create
(
eval_metric
,
**
eval_metric_params
)
for
batch_i
,
batch
in
enumerate
(
test_iter
):
if
True
:
if
True
:
labels
=
[
batch
.
label
[
i
].
as_in_context
(
mx_context
)
for
i
in
range
(
1
)]
data_
=
batch
.
data
[
0
].
as_in_context
(
mx_context
)
...
...
@@ -406,7 +407,7 @@ class CNNSupervisedTrainer_VGG16:
attention_resized
=
np
.
resize
(
attention
.
asnumpy
(),
(
8
,
8
))
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
l
+
1
)
ax
.
set_title
(
dict
[
int
(
mx
.
nd
.
slice_axis
(
mx
.
nd
.
argmax
(
outputs
[
l
+
1
],
axis
=
1
),
axis
=
0
,
begin
=
0
,
end
=
1
).
asscalar
())])
img
=
ax
.
imshow
(
test_images
[
0
+
test_batch_size
*
(
batch_i
)])
img
=
ax
.
imshow
(
test_images
[
0
+
test_batch_size
*
(
batch_i
)]
.
transpose
(
1
,
2
,
0
)
)
ax
.
imshow
(
attention_resized
,
cmap
=
'gray'
,
alpha
=
0.6
,
extent
=
img
.
get_extent
())
...
...
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