Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bård Sørensen Hestmark
IDATT2900 45b
Commits
d1d867ca
Commit
d1d867ca
authored
May 09, 2022
by
Bård Sørensen Hestmark
Browse files
imggen
parent
b94c2847
Changes
4
Hide whitespace changes
Inline
Side-by-side
CA-ES/es.py
View file @
d1d867ca
import
copy
import
math
from
tqdm
import
trange
import
multiprocessing
as
mp
import
numpy
as
np
import
torch
...
...
@@ -226,21 +225,4 @@ class ES:
self
.
writer
.
add_scalar
(
"growth_loss/200"
,
growth_loss
[
1
],
iteration
)
save_image
(
torch
.
cat
(
pics
,
dim
=
0
),
'%s/pic/big%04d.png'
%
(
self
.
logdir
,
iteration
),
nrow
=
1
,
padding
=
0
)
save_model
(
self
.
net
,
self
.
logdir
+
"/models/model_"
+
str
(
iteration
))
# if mean_fit > -0.003:
# logging.info("Training goal reached, exiting")
# break
def
generate_graphic
(
self
):
model
=
self
.
net
x_eval
=
tt
(
np
.
repeat
(
self
.
seed
[
None
,
...],
self
.
batch_size
,
0
))
pics
=
[]
pics
.
append
(
to_rgb
(
x_eval
).
permute
(
0
,
3
,
1
,
2
))
for
eval
in
range
(
40
):
x_eval
=
model
(
x_eval
)
if
eval
in
[
10
,
20
,
30
,
39
]:
# frames to save img of
pics
.
append
(
to_rgb
(
x_eval
).
permute
(
0
,
3
,
1
,
2
))
save_image
(
torch
.
cat
(
pics
,
dim
=
0
),
'%s/graphic.png'
%
(
self
.
logdir
),
nrow
=
len
(
pics
),
padding
=
0
)
\ No newline at end of file
interactive_CA/interactive.py
View file @
d1d867ca
...
...
@@ -212,3 +212,22 @@ class Interactive:
print
(
'Reached 400 iterations. Shutting down...'
)
pygame
.
quit
()
sys
.
exit
()
def
generate_graphic
(
self
):
model
=
self
.
net
x_eval
=
self
.
seedclone
()
pics
=
[]
pics
.
append
(
to_rgb
(
x_eval
).
permute
(
0
,
3
,
1
,
2
))
for
eval
in
range
(
40
):
x_eval
=
model
(
x_eval
)
if
eval
in
[
4
,
9
,
20
,
39
]:
# frames to save img of
if
self
.
es
:
image
=
to_rgb
(
x_eval
).
permute
(
0
,
3
,
1
,
2
)
else
:
image
=
to_rgb_ad
(
x_eval
[:,
:
4
].
detach
().
cpu
())
pics
.
append
(
image
)
save_image
(
torch
.
cat
(
pics
,
dim
=
0
),
'%s/graphic.png'
%
(
self
.
logdir
),
nrow
=
len
(
pics
),
padding
=
0
)
interactive_CA/main.py
View file @
d1d867ca
...
...
@@ -54,7 +54,7 @@ if __name__ == '__main__':
"Logging directory '%s' not found in base folder"
%
args
.
logdir
)
match
args
.
es
:
case
'True'
:
case
'True'
:
#heh
method
=
'ES'
args
.
es
=
True
case
'False'
:
...
...
@@ -76,3 +76,4 @@ if __name__ == '__main__':
Interactive
=
Interactive
(
args
)
Interactive
.
interactive
()
# Interactive.generate_graphic_es()
interactive_CA/run_all.py
View file @
d1d867ca
...
...
@@ -33,20 +33,20 @@ models = [adam_nonsample_models, adam_sample_models,
if
__name__
==
'__main__'
:
# Run all models:
for
i
in
models
:
for
model
in
i
:
load_model
=
model
[
0
]
emoji
=
model
[
1
]
size
=
model
[
2
]
es
=
model
[
3
]
command
=
"python .\interactive_CA\main.py -i %s -s %i -l %s -e %r"
%
(
emoji
,
size
,
load_model
,
es
)
subprocess
.
run
(
command
)
#
for i in models:
#
for model in i:
#
load_model = model[0]
#
emoji = model[1]
#
size = model[2]
#
es = model[3]
#
command = "python .\interactive_CA\main.py -i %s -s %i -l %s -e %r" % (emoji, size, load_model, es)
#
subprocess.run(command)
# # Run single model:
# model = models[3][2]
# load_model = model[0]
# emoji = model[1]
# size = model[2]
# es = model[3]
# command = "python .\interactive_CA\main.py -i %s -s %i -l %s -e %r" % (emoji, size, load_model, es)
# subprocess.run(command)
\ No newline at end of file
model
=
models
[
3
][
2
]
load_model
=
model
[
0
]
emoji
=
model
[
1
]
size
=
model
[
2
]
es
=
model
[
3
]
command
=
"python .\interactive_CA\main.py -i %s -s %i -l %s -e %r"
%
(
emoji
,
size
,
load_model
,
es
)
subprocess
.
run
(
command
)
\ No newline at end of file
Bård Sørensen Hestmark
@baardshe
mentioned in commit
ad9f026b
·
Jun 21, 2022
mentioned in commit
ad9f026b
mentioned in commit ad9f026baadaf2cd922815d6b4d1fb68d4120cbb
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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