ehsanhaghighat / sciann

Deep learning for Engineers - Physics Informed Deep Learning
htttp://sciann.com
Other
325 stars 116 forks source link

PyPI Version Build Status Downloads Downloads Downloads License

:warning: NOTE :warning:

Thanks for your interest in this project. This project is no longer maintained, so please be aware of that. The last tests are based on python==3.9 and tensorflow==2.10. It should be less sensitive to Python updates, but Keras / TensorFlow changes rapidly. So I strongly advise to use SciANN on TensorFlow/Keras == 2.10.

SciANN: Neural Networks for Scientific Computations

SciANN is a Keras wrapper for scientific computations and physics-informed deep learning.

New to SciANN?

SciANN is a high-level artificial neural networks API, written in Python using Keras and TensorFlow backends. It is developed with a focus on enabling fast experimentation with different networks architectures and with emphasis on scientific computations, physics informed deep learing, and inversion. Being able to start deep-learning in a very few lines of code is key to doing good research.

Use SciANN if you need a deep learning library that:

For more details, check out our review paper at https://arxiv.org/abs/2005.08803 and the documentation at SciANN.com.

Cite SciANN in your publications if it helps your research:

@article{haghighat2021sciann,
  title={SciANN: A Keras/TensorFlow wrapper for scientific computations and physics-informed deep learning using artificial neural networks},
  author={Haghighat, Ehsan and Juanes, Ruben},
  journal={Computer Methods in Applied Mechanics and Engineering},
  volume={373},
  pages={113552},
  year={2021},
  publisher={Elsevier}
}

SciANN is compatible with: Python 3.8-3.10.

Have questions or like collaborations, email Ehsan Haghighat.


Getting started: 30 seconds to SciANN

The core data structure of SciANN is a Functional, a way to organize inputs (Variables) and outputs (Fields) of a network.

Targets are imposed on Functional instances using Constraints.

The SciANN model (SciModel) is formed from inputs (Variables) and targets(Constraints). The model is then trained by calling the solve function.

Here is the simplest SciANN model:

from sciann import Variable, Functional, SciModel
from sciann.constraints import Data

x = Variable('x')
y = Functional('y')

# y_true is a Numpy array of (N,1) -- with N as number of samples.  
model = SciModel(x, Data(y))

This is associated to the simplest neural network possible, i.e. a linear relation between the input variable x and the output variable y with only two parameters to be learned.

Plotting a network is as easy as passing a file_name to the SciModel:

model = SciModel(x, Data(y), plot_to_file='file_path')

Once your model looks good, perform the learning with .solve():

# x_true is a Numpy array of (N,1) -- with N as number of samples. 
model.train(x_true, y_true, epochs=5, batch_size=32)

You can iterate on your training data in batches and in multiple epochs. Please check Keras documentation on model.fit for more information on possible options.

You can evaluate the model any time on new data:

classes = model.predict(x_test, batch_size=128)

In the application folder of the repository, you will find some examples of Linear Elasticity, Flow, Flow in Porous Media, etc.


Installation

Before installing SciANN, you need to install the TensorFlow and Keras.

You may also consider installing the following optional dependencies:

Then, you can install SciANN itself. There are two ways to install SciANN:

Note: These installation steps assume that you are on a Linux or Mac environment. If you are on Windows, you will need to remove sudo to run the commands below.

sudo pip install sciann

If you are using a virtualenv, you may want to avoid using sudo:

pip install sciann

Note: To install tensorflow/sicann on M1 Apple systems, do the following:

conda install -c apple tensorflow-deps=2.9.0
pip install tensorflow-macos=2.9.0
conda install matpltlib pandas    #(ETC)

and then

pip install sciann-macos

First, clone SciANN using git:

git clone https://github.com/sciann/sciann.git

Then, cd to the SciANN folder and run the install command:

sudo python setup.py install

or

sudo pip install .

Why this name, SciANN?

Scientific Computational with Artificial Neural Networks.

Scientific computations include solving ODEs, PDEs, Integration, Differentiation, Curve Fitting, etc.