Helper functions for NSE as LPV with Neural Networks
Project description
Neural Networks for NSE as low-dimensional LPV
Active workflow
Installation
# package for sparse cholesky factorizations
# not needed but speed up with FEM norms and POD
apt install libsuitesparse-dev
pip install scikit-sparse==0.4.5
# fenics -- for the FEM part
apt install fenics # see https://fenicsproject.org/download/
# install this module and helper modules
pip install .
Generate the data
cd ../simulations-training-data
mkdir cached-data
mkdir train-data
source single-cylinder-tdp-sim.sh
# source double-cylinder-tdp-sim.sh
# python3 time_dep_nse_generic.py
cd -
Check the NN
python3 data_fem_checks.py
python3 CNN_AE.py
Data and Handling
Generally, the data is
- generated by the simulation
- interpolated to the pictures
- imported to PyTorch as tensors
The relevant formats and routines are as follows:
import nse_nn_lpv.nse_data_helpers as ndh
time_dep_nse_generic.py
computes the trajectories with snapshotsvvec
and interpolates them to the two picturesvmatx
andvmaty
at all time instancesti
. The data is stored as ajson
file, say,data.json
like
{ti: {'vvec': vvec, 'vmatx': vmatx, 'vmaty': vmaty},
'femdata': 'information of the simulation ...'}
(datal, vvecl) = ndh.get_nse_img_data('data.json')
takes the data filedata.json
and returns the data as a list (of tuples) ofnumpy
arrays:
datal = [(vmatx, vmaty, t_0), ..., (vmatx, vmaty, t_end)]
vvecl = [vvec_0, ..., ..., ..., ..., vvec_end]
-
trn_nse_data = ndh.NSEDataset(nsedatal, vvecl)
takes the data lists and makes it available as apytorch
data set. In particular, the two picturesvmatx
,vmaty
are merged into a tensor. -
stst_dataloader = pytorch.DataLoader(trn_nse_data, batch_size=1, shuffle=True)
then defines a way to access the data. E.g.,
(ttstset, tstvec) = next(iter(stst_dataloader))
returns a data point via
ttstset
: the tensor of size(batch_size, 2, width, height)
, where(width, height)
are the dimensions of the pictureststvec
: the correspondingvvecs
(needed, e.g., for the loss function later)
Python Machine-Learning Resources
- an overview
- Tensorflow -- see below
- Pytorch -- see below
- NeuroLab
- ffnet
- Scikit-Neural Network
- Lasagne
- pyrenn
Tensorflow
- website
- Article for understanding NN using TensorFlow
- Previous experience with building NN
- Visualization feature TensorBoard
- Based on keras
PyTorch
- website
- Tutorial for simple NN
- Recommended by colleagues (Lessig, Richter)
Scikit-Learn
- website
- looks well maintained
- many routines for data processing
- a few on neural network
Install
# not needed anymore
# pip install -e . # Python3 needed here! install the module (and one dependency)
pip install -e
installs the module nse_nn_lpv
to be used in the tests/...
but keeps track of all changes made in nse_nn_lpv
.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nse_nn_lpv-0.1.1.tar.gz
(12.7 kB
view hashes)
Built Distribution
nse_nn_lpv-0.1.1-py3-none-any.whl
(11.6 kB
view hashes)
Close
Hashes for nse_nn_lpv-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58fed2de62f6b967714869ca4e467f1305d8fece49db3c20201fd68df9cf969f |
|
MD5 | 1b056ba07fe0cef9947b909807c4cf2a |
|
BLAKE2b-256 | c6de563239a18612bec090ed432253cc76ff701f2f4054420f71c622c8092d34 |