Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
KiT-RT
KiT-RT
Commits
0c7ec318
Commit
0c7ec318
authored
Oct 27, 2020
by
steffen.schotthoefer
Browse files
tidy up
parent
16e462ad
Pipeline
#115651
failed with stage
in 13 minutes and 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
code/input/exampleMN.cfg
View file @
0c7ec318
...
...
@@ -29,10 +29,10 @@ CFL_NUMBER = 0.7
% Final time for simulation
TIME_FINAL = 0.3
% Maximal Moment degree
MAX_MOMENT_SOLVER =
1
MAX_MOMENT_SOLVER =
0
%
%% Entropy settings
ENTROPY_FUNCTIONAL = MAXWELL_BOLZMANN
ENTROPY_FUNCTIONAL = MAXWELL_BOL
T
ZMANN
ENTROPY_OPTIMIZER = NEWTON
%
% ----- Newton Solver Specifications ----
...
...
code/python/callNN.py
deleted
100644 → 0
View file @
16e462ad
# imports
import
tensorflow
as
tf
import
numpy
as
np
import
math
# Custom Loss
def
custom_loss1dMBPrime
():
# (label,prediciton)
def
loss
(
u_input
,
alpha_pred
):
return
0.5
*
tf
.
square
(
4
*
math
.
pi
*
np
.
sqrt
(
1
/
(
4
*
np
.
pi
))
*
tf
.
math
.
exp
(
alpha_pred
*
np
.
sqrt
(
1
/
(
4
*
np
.
pi
)))
-
u_input
)
return
loss
def
initialize_network
():
# Load model
model
=
tf
.
keras
.
models
.
load_model
(
'neural_network_model/_EntropyLoss_1_300_M_0'
,
custom_objects
=
{
'loss'
:
custom_loss1dMBPrime
})
# Check its architecture
model
.
summary
()
return
model
# make the network a gobal variable here
model
=
initialize_network
()
def
call_network
(
input
):
inputNP
=
np
.
asarray
([
input
])
predictions
=
model
.
predict
(
inputNP
)
return
predictions
[
0
]
def
call_networkBatchwise
(
input
):
#print(input)
inputNP
=
np
.
asarray
(
input
)
#print(inputNP.shape)
#print(inputNP)
predictions
=
model
.
predict
(
inputNP
)
#print(predictions)
size
=
predictions
.
shape
[
0
]
*
predictions
.
shape
[
1
]
test
=
np
.
zeros
(
size
)
for
i
in
range
(
0
,
size
):
test
[
i
]
=
predictions
.
flatten
(
order
=
'C'
)[
i
]
return
test
#return predictions.flatten(order='C')[0]
def
main
():
input
=
[[
1
],
[
2
],
[
3
],
[
2
],
[
3
],
[
4
],
[
5
]]
# initialize_network()
print
(
call_network
(
1
))
print
(
"-----"
)
print
(
call_networkBatchwise
(
input
))
return
0
if
__name__
==
'__main__'
:
main
()
steffen.schotthoefer
@kx5574
mentioned in commit
4fb80b1a
·
Apr 30, 2021
mentioned in commit
4fb80b1a
mentioned in commit 4fb80b1a3715344d465b0ed0cdde630f3a685705
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