Commit 4fb80b1a authored by steffen.schotthoefer's avatar steffen.schotthoefer
Browse files

tidy up


Former-commit-id: 0c7ec318
parent ba594f58
......@@ -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_BOLTZMANN
ENTROPY_OPTIMIZER = NEWTON
%
% ----- Newton Solver Specifications ----
......
# 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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment