Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
EMADL2CPP
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
10
Issues
10
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
EMADL2CPP
Commits
d52a04a2
Commit
d52a04a2
authored
Nov 27, 2019
by
Christian Fuß
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed tests
parent
a8440765
Pipeline
#211648
failed with stages
in 23 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
19 deletions
+7
-19
src/test/resources/target_code/gluon/CNNSupervisedTrainer_mnist_mnistClassifier_net.py
...e/gluon/CNNSupervisedTrainer_mnist_mnistClassifier_net.py
+7
-19
No files found.
src/test/resources/target_code/gluon/CNNSupervisedTrainer_mnist_mnistClassifier_net.py
View file @
d52a04a2
...
...
@@ -352,21 +352,16 @@ class CNNSupervisedTrainer_mnist_mnistClassifier_net:
with
open
(
'src/test/resources/training_data/Show_attend_tell/dict.pkl'
,
'rb'
)
as
f
:
dict
=
pickle
.
load
(
f
)
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
1
)
ax
.
imshow
(
train_images
[
0
+
test_batch_size
*
(
batch_i
)].
transpose
(
1
,
2
,
0
))
for
l
in
range
(
max_length
):
attention
=
attentionList
[
l
]
attention
=
mx
.
nd
.
slice_axis
(
attention
,
axis
=
0
,
begin
=
0
,
end
=
1
)
attention
=
mx
.
nd
.
squeeze
(
attention
)
attention
=
mx
.
nd
.
slice_axis
(
attention
,
axis
=
0
,
begin
=
0
,
end
=
1
).
squeeze
()
attention_resized
=
np
.
resize
(
attention
.
asnumpy
(),
(
8
,
8
))
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
l
+
2
)
if
int
(
labels
[
l
+
1
][
0
].
asscalar
())
>
len
(
dict
):
ax
.
set_title
(
"<unk>"
)
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
())
break
elif
dict
[
int
(
labels
[
l
+
1
][
0
].
asscalar
())]
==
"<end>"
:
ax
.
set_title
(
"."
)
img
=
ax
.
imshow
(
train_images
[
0
+
test_batch_size
*
(
batch_i
)].
transpose
(
1
,
2
,
0
))
...
...
@@ -374,14 +369,13 @@ class CNNSupervisedTrainer_mnist_mnistClassifier_net:
break
else
:
ax
.
set_title
(
dict
[
int
(
labels
[
l
+
1
][
0
].
asscalar
())])
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
())
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
())
plt
.
tight_layout
()
target_dir
=
'target/attention_images'
if
not
os
.
path
.
exists
(
target_dir
):
os
.
makedirs
(
target_dir
)
os
.
makedirs
(
target_dir
)
plt
.
savefig
(
target_dir
+
'/attention_train.png'
)
plt
.
close
()
...
...
@@ -420,21 +414,16 @@ class CNNSupervisedTrainer_mnist_mnistClassifier_net:
fig
=
plt
.
figure
(
figsize
=
(
15
,
15
))
max_length
=
len
(
labels
)
-
1
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
1
)
ax
.
imshow
(
test_images
[
0
+
test_batch_size
*
(
batch_i
)].
transpose
(
1
,
2
,
0
))
for
l
in
range
(
max_length
):
attention
=
attentionList
[
l
]
attention
=
mx
.
nd
.
slice_axis
(
attention
,
axis
=
0
,
begin
=
0
,
end
=
1
)
attention
=
mx
.
nd
.
squeeze
(
attention
)
attention
=
mx
.
nd
.
slice_axis
(
attention
,
axis
=
0
,
begin
=
0
,
end
=
1
).
squeeze
()
attention_resized
=
np
.
resize
(
attention
.
asnumpy
(),
(
8
,
8
))
ax
=
fig
.
add_subplot
(
max_length
//
3
,
max_length
//
4
,
l
+
2
)
if
int
(
mx
.
nd
.
slice_axis
(
outputs
[
l
+
1
],
axis
=
0
,
begin
=
0
,
end
=
1
).
squeeze
().
asscalar
())
>
len
(
dict
):
ax
.
set_title
(
"<unk>"
)
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
())
break
elif
dict
[
int
(
mx
.
nd
.
slice_axis
(
outputs
[
l
+
1
],
axis
=
0
,
begin
=
0
,
end
=
1
).
squeeze
().
asscalar
())]
==
"<end>"
:
ax
.
set_title
(
"."
)
img
=
ax
.
imshow
(
test_images
[
0
+
test_batch_size
*
(
batch_i
)].
transpose
(
1
,
2
,
0
))
...
...
@@ -442,9 +431,8 @@ class CNNSupervisedTrainer_mnist_mnistClassifier_net:
break
else
:
ax
.
set_title
(
dict
[
int
(
mx
.
nd
.
slice_axis
(
outputs
[
l
+
1
],
axis
=
0
,
begin
=
0
,
end
=
1
).
squeeze
().
asscalar
())])
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
())
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
())
plt
.
tight_layout
()
plt
.
savefig
(
target_dir
+
'/attention_test.png'
)
...
...
Christian Fuß
@chrifuss
mentioned in commit
749446ef
·
Dec 06, 2019
mentioned in commit
749446ef
mentioned in commit 749446efff53a7e6014c49f2e8e93145e26ca6c6
Toggle commit list
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