-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RomApp] Adding training routine for neural networks to be used in ANN-PROM #11988
Conversation
Done in order to properly follow the Kratos Style Guide Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es. Replaced os module with pathlib.
I corrected naming mistakes and the check routine for the Rom Manager parameters, as pointed out in the comments. |
class TestNeuralNetworkTrainerClass(KratosUnittest.TestCase): | ||
|
||
def setUp(self): | ||
self.reference_relative_error = 0.0009752321235806322 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too hardcoded?
@roigcarlo Could you check this PR? in particular the test for Tensorflow |
From my side no problem with the TF test 👍 |
…option in the ROM parameters.
…if trying to use NN_trainer
📝 Description
This pull request is the first one in the path to incorporate ANN-PROM into the ROM Application. Here we just deal with the training of the neural networks via Tensorflow.
These neural networks use a certain amount of modes from the POD as input, and learn to predict the next few ones.
The data used for training the net is the same as the one for training POD, except that in this case also the singular values are needed along with an additional dataset of snapshots for the validation.
Once trained, the neural network files (architecture configuration and weights) are saved so that they can be used later.
The usage is via de RomManager by calling:
rom_manager.FitNeuralNetwork(mu_train, mu_test)
: To create the training and validation datasets (based on the parameters inmu_train
andmu_test
) and then train the NN itself.rom_manager.TestNeuralNetwork()
: To evaluate an already-existing NN.And needs some configuration to be added in the
general_rom_manager_parameters
json:"rom_stages_nn_fit"
: To define which tasks we want to perform in theFitNeuralNetwork()
method"neural_network"
: To define the root path for the NN model files, the architecture to be used, and the hyperparameters for the training in tensorflow.An example of these configuration parameters will be added in the examples repository
🆕 Changelog
Added
RomNeuralNetworkTrainer
class.In rom_manager.py:
FitNeuralNetwork(mu_train, mu_test)
andTestNeuralNetwork()
methods__LaunchTrainNeuralNetwork()
and__LaunchTestNeuralNetwork()
methodsRunFOM()
and__LaunchRunFOM
to enable saving the produced snapshot matrixIn calculate_rom_basis_output_process.py, modified
_PrintRomBasis(snapshots_matrix)
to save singular values in a npy file