This repository contains an implementation of Tensorized Physics Informed Neural Networks (TPINNs) for solving physics-based problems. TPINNs combine the power of neural networks with the physical laws governing the system to improve accuracy and generalization. 🚀
Tensorized Physics Informed Neural Networks (TPINNs) are a class of neural networks that incorporate known physical laws into their architecture. By including the governing equations of a system as constraints, TPINNs can solve complex physics-based problems more accurately than traditional neural networks. This repository provides an implementation of TPINNs using TensorFlow. ♾️
To run the code in this repository, you need the following dependencies:
- Python (>= 3.6)
- TensorFlow (>= 2.0)
- NumPy (>= 1.18)
- Clone the repository:
git clone [email protected]:mvanzulli/TPINN.git - Navigate to the project directory:
cd TPINN - Install the required dependencies:
pip install -r requirements.txt
To utilize TPINNs in your own projects, follow these steps:
-
Import the necessary modules:
import tensorflow as tf import numpy as np from tn_layer import TNLayer from tn_model import TNModel
-
Create an instance of the TNLayer class:
tn_layer = TNLayer(input_dim, bond_dim, activation, kernel_initializer, use_bias, bias_initializer)
Replace the arguments with the desired values.
input_dimis the dimensionality of the input tensor,bond_dimis the bond dimension of the TN layer,activationis the activation function to use,kernel_initializeris the initializer for the weight matrices,use_biasspecifies whether to include a bias term, andbias_initializeris the initializer for the bias term. -
Create an instance of the TNModel class:
tn_model = TNModel(num_layers, MPO_units, output_dim, bond_dim, activation, use_bias, kernel_initializer, bias_initializer, dif_equation)
Replace the arguments with the desired values.
num_layersis the number of TN layers,MPO_unitsis the number of units in the MPO tensor,output_dimis the dimension of the output,bond_dimis the bond dimension of the TN layer (optional),activationis the activation function to use,use_biasspecifies whether to include a bias term,kernel_initializeris the initializer for the weight matrices,bias_initializeris the initializer for the bias term, anddif_equationis a callable representing the one-dimensional fourth-order PDE. -
Use the TNModel to perform forward pass and compute the PDE loss:
y_pred = tn_model.call(x) pde_loss = tn_model.compute_pde_loss(x)
Replace
xwith the input tensor.
An example usage of TPINNs can be found in the examples directory. It demonstrates how to solve a physics-based problem using TPINNs.
Contributions to this repository are welcome. Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.