### Install PINA with Extra Packages Source: https://github.com/mathlab/pina/blob/master/docs/source/_installation.rst Installs PINA along with specified extra dependencies for development, testing, documentation, or tutorials. ```bash $ pip install "pina-mathlab[extras]" ``` -------------------------------- ### Install PINA from Source Source: https://github.com/mathlab/pina/blob/master/docs/source/_installation.rst Installs the PINA package from its source code after cloning the repository. This uses an editable install. ```bash $ pip install -e . ``` -------------------------------- ### Clone PINA Repository from GitHub Source: https://github.com/mathlab/pina/blob/master/docs/source/_installation.rst Clones the official PINA repository from GitHub to install the package from source. ```bash $ git clone https://github.com/mathLab/PINA ``` -------------------------------- ### Install PINA via PIP Source: https://github.com/mathlab/pina/blob/master/docs/source/_installation.rst Installs the PINA library using pip for Mac and Linux users. This command fetches pre-built binary packages. ```bash $ pip install pina-mathlab ``` -------------------------------- ### Install PINA with Tutorial Extras Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial16/tutorial.html Installs the PINA library with tutorial extras, necessary for running the examples in this notebook. This command is typically run in a Google Colab environment. ```shell !pip install "pina-mathlab[tutorial]" ``` -------------------------------- ### Setup for PINA Tutorials (Python) Source: https://github.com/mathlab/pina/blob/master/tutorials/TUTORIAL_GUIDELINES.md This Python snippet handles notebook execution on Google Colab and installs necessary PINA packages. It also imports common libraries like torch and matplotlib, and sets up warning filters for a cleaner output. ```python ## Routine needed to run the notebook on Google Colab try: import google.colab IN_COLAB = True except: IN_COLAB = False if IN_COLAB: !pip install "pina-mathlab[tutorial]" import torch # if used import matplotlib.pyplot as plt # if used import warnings # if needed warnings.filterwarnings("ignore") # Additional PINA and problem-specific imports ... ``` -------------------------------- ### Install PINA with tutorial extras Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial18/tutorial.html Installs the PINA library with extra dependencies required for tutorials, specifically for use in Google Colab environments. ```bash #!pip install "pina-mathlab[tutorial]" ``` -------------------------------- ### Install PINA from Source Source: https://github.com/mathlab/pina/blob/master/README.md Installs PINA by cloning the repository and building from source. This is useful for development or when needing the latest unreleased features. It requires git and Python environment setup. ```sh git clone https://github.com/mathLab/PINA cd PINA git checkout master pip install . ``` -------------------------------- ### Install PINA and Download Data (Colab) Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial7/tutorial.html Installs the PINA library with tutorial dependencies and downloads necessary data files if running in a Google Colab environment. This setup ensures all required components are available for the tutorial. ```python import google.colab IN_COLAB = True except: IN_COLAB = False if IN_COLAB: !pip install "pina-mathlab[tutorial]" !mkdir "data" !wget "https://github.com/mathLab/PINA/raw/refs/heads/master/tutorials/tutorial7/data/pinn_solution_0.5_0.5" -O "data/pinn_solution_0.5_0.5" !wget "https://github.com/mathLab/PINA/raw/refs/heads/master/tutorials/tutorial7/data/pts_0.5_0.5" -O "data/pts_0.5_0.5" ``` -------------------------------- ### Install PINA with Tutorial Extras Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial1/tutorial.html Installs the PINA library with the necessary dependencies for running tutorials, specifically designed for Google Colab environments. ```python import google.colab IN_COLAB = True except: IN_COLAB = False if IN_COLAB: !pip install "pina-mathlab[tutorial]" ``` -------------------------------- ### Install PINA with Tutorial Dependencies Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial21/tutorial.html Installs the PINA library with the necessary dependencies for running tutorials, specifically for Google Colab environments. It checks if the script is running in Colab and then uses pip to install the package. ```python import torch import matplotlib.pyplot as plt import warnings warnings.filterwarnings("ignore") from pina import Trainer from pina.solver import SupervisedSolver from pina.model import KernelNeuralOperator from pina.model.block import FourierBlock1D from pina.problem.zoo import SupervisedProblem ``` -------------------------------- ### PINN Model Training Setup and Execution (Python) Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial7/tutorial.html This code snippet initializes a PINN model with a specified problem and optimizer, then configures and starts a PyTorch Lightning Trainer. It sets training parameters like maximum epochs, accelerator, default root directory, and includes the custom SaveParameters callback. The trainer is configured to use 100% of the data for training. ```python max_epochs = 1500 pinn = PINN( problem, model, optimizer=TorchOptimizer(torch.optim.Adam, lr=0.005) ) # define the trainer for the solver trainer = Trainer( solver=pinn, accelerator="cpu", max_epochs=max_epochs, default_root_dir=tmp_dir, enable_model_summary=False, callbacks=[SaveParameters()], train_size=1.0, val_size=0.0, test_size=0.0, ) trainer.train() ``` -------------------------------- ### Install PINA and Dependencies for Colab Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial5/tutorial.html Installs the PINA library with tutorial extras and SciPy for use in Google Colab. It also downloads the necessary dataset for the Darcy Flow problem. ```python try: import google.colab IN_COLAB = True except: IN_COLAB = False if IN_COLAB: !pip install "pina-mathlab[tutorial]" !pip install scipy # get the data !wget https://github.com/mathLab/PINA/raw/refs/heads/master/tutorials/tutorial5/Data_Darcy.mat ``` -------------------------------- ### Install PINA with Tutorial Dependencies Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial15/tutorial.html Installs the PINA library with extra dependencies required for running tutorials, specifically for use within Google Colab environments. ```python try: import google.colab IN_COLAB = True except: IN_COLAB = False if IN_COLAB: !pip install "pina-mathlab[tutorial]" ``` -------------------------------- ### Install PINA with Extra Packages Source: https://github.com/mathlab/pina/blob/master/README.md Installs PINA along with optional dependencies for specific use cases like development ('dev'), testing ('test'), documentation building ('doc'), or running tutorials ('tutorial'). ```sh pip install "pina-mathlab[extras]" ``` -------------------------------- ### Install PINA and Import Libraries Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial19/tutorial.html Installs the PINA library with tutorial dependencies if running in Google Colab and imports necessary libraries like torch, Data from torch_geometric, LabelTensor, and Graph from PINA. ```python import warnings import torch from torch_geometric.data import Data warnings.filterwarnings("ignore") from pina import LabelTensor, Graph ``` -------------------------------- ### PINA Model Training Setup (PyTorch) Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial3/tutorial.html Sets up and trains a PINN model using the PINA library. This includes discretizing the domain, defining the custom `HardMLP` model, creating a `PINN` solver, and configuring a `Trainer` with specific epochs and callbacks. ```python # generate the data problem.discretise_domain(1000, "random", domains"all") # define model model = HardMLP(len(problem.input_variables), len(problem.output_variables)) # crete the solver pinn = PINN(problem=problem, model=model) # create trainer and train trainer = Trainer( solver=pinn, max_epochs=1000, accelerator="cpu", enable_model_summary=False, train_size=1.0, val_size=0.0, test_size=0.0, callbacks=[MetricTracker(["train_loss", "initial_loss", "D_loss"])] ) trainer.train() ``` -------------------------------- ### Install PINA Stable Release using Pip Source: https://github.com/mathlab/pina/blob/master/README.md Installs the latest stable version of the PINA library from PyPI using pip. This is the recommended method for most users. ```sh pip install "pina-mathlab" ``` -------------------------------- ### PINA Library Imports and Setup Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial7/tutorial.html Imports essential libraries and modules from PINA, PyTorch, and Matplotlib for building and training PINNs. It also includes warning filters and sets a random seed for reproducibility. ```python import matplotlib.pyplot as plt import torch import warnings from lightning.pytorch import seed_everything from lightning.pytorch.callbacks import Callback from pina import Condition, Trainer from pina.problem import SpatialProblem, InverseProblem from pina.operator import laplacian from pina.model import FeedForward from pina.equation import Equation, FixedValue from pina.solver import PINN from pina.domain import CartesianDomain from pina.optim import TorchOptimizer warnings.filterwarnings("ignore") seed_everything(883) ``` -------------------------------- ### Exception Handling in Java Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial3/tutorial.html Provides a basic example of exception handling in Java using `try-catch` blocks to manage potential runtime errors. ```java public class ExceptionHandling { public static void main(String[] args) { try { int result = 10 / 0; // This will cause an ArithmeticException System.out.println("Result: " + result); } catch (ArithmeticException e) { System.err.println("Error: Cannot divide by zero."); } } } ``` -------------------------------- ### Jupyter HTML Widget Model Configuration Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial11/tutorial.html Defines the configuration for a Jupyter HTML widget, including its model name, module, and version. This is a standard setup for interactive HTML elements in Jupyter environments. ```json { "model_name": "HTMLModel", "model_module": "@jupyter-widgets\/controls", "model_module_version": "2.0.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets\/controls", "_model_module_version": "2.0.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets\/controls", "_view_module_version": "2.0.0", "_view_name": "HTMLView", "description": "", "description_allow_html": false, "layout": "IPY_MODEL_347b288a105f4466a0d23c171caadf5c", "placeholder": "\u200b", "style": "IPY_MODEL_754f3bf628c74a23b61891e483467c9a", "tabbable": null, "tooltip": null, "value": "Epoch\u2007499:\u2007100%" } } ``` -------------------------------- ### Uninstall PINA via PIP Source: https://github.com/mathlab/pina/blob/master/docs/source/_installation.rst Uninstalls the PINA library from the system using pip. ```bash $ pip uninstall pina-mathlab ``` -------------------------------- ### Import PINA modules and set up environment Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial11/tutorial.html Imports necessary libraries including torch, warnings, and core PINA components like Trainer, SupervisedSolver, FeedForward, and SupervisedProblem. It also includes a check for the Google Colab environment and suppresses warnings. ```python import torch import warnings from pina import Trainer from pina.solver import SupervisedSolver from pina.model import FeedForward from pina.problem.zoo import SupervisedProblem warnings.filterwarnings("ignore") ``` -------------------------------- ### Solver Initialization Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial1/tutorial.html Shows how to initialize a PINN solver with a model, problem definition, and an optimizer. ```APIDOC ## Solver Initialization ### Description Initialize a Physics-Informed Neural Network (PINN) solver. The solver requires a problem definition and a model. It also accepts an optimizer, scheduler, loss type, and weighting for different conditions, which are set to their default values if not specified. ### Method N/A (Code Example) ### Endpoint N/A ### Parameters #### Request Body - **problem** (PINA Problem Object) - Required - The physics problem to solve. - **model** (PINA Model Object) - Required - The neural network model. - **optimizer** (PINA Optimizer Wrapper) - Required - The optimizer for training (e.g., `TorchOptimizer(torch.optim.RAdam, lr=0.005)`). ### Request Example ```python import torch from pina.solver import PINN from pina.optim import TorchOptimizer # Assuming 'problem' and 'model' are already defined # model = FeedForward(...) # problem = ... pinn = PINN(problem, model, TorchOptimizer(torch.optim.RAdam, lr=0.005)) ``` ### Response #### Success Response (200) - **pinn_solver** (object) - The initialized PINN solver instance. #### Response Example ``` ``` ### Bonus Tip All physics solvers in PINA can handle both forward and inverse problems without requiring any changes to the model or solver structure. Refer to the PINA tutorial on inverse problems for more information. ``` -------------------------------- ### PINA Trainer Setup and Data Preparation Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial8/tutorial.html This code configures and sets up the PINA Trainer for a supervised learning task. It defines training parameters such as maximum epochs, batch size, accelerator, and data split ratios (train, validation, test). It then sets up the data module and extracts training data. ```python trainer = Trainer( solver=pod_nn_stokes, max_epochs=1000, batch_size=None, accelerator="cpu", train_size=0.9, val_size=0.0, test_size=0.1, ) # fit the pod basis trainer.data_module.setup("fit") # set up the dataset train_data = trainer.data_module.train_dataset.get_all_data() x_train = train_data["data"]["target"] # extract data for training pod_nn.fit_pod(x=x_train) ``` -------------------------------- ### Training Configuration and Execution (Python) Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial3/tutorial.html Sets up and initiates the training process for the `HardMLPtime` model. It configures the solver, trainer with specified epochs, accelerator, and callbacks for metric tracking. This snippet assumes a `problem` object and `PINN` and `Trainer` classes are defined elsewhere. ```python # define model model = HardMLPtime(len(problem.input_variables), len(problem.output_variables)) # crete the solver pinn = PINN(problem=problem, model=model) # create trainer and train trainer = Trainer( solver=pinn, max_epochs=1000, accelerator="cpu", enable_model_summary=False, train_size=1.0, val_size=0.0, test_size=0.0, callbacks=[MetricTracker(["train_loss", "initial_loss", "D_loss"])] ) trainer.train() ``` -------------------------------- ### Set up Supervised Problem and Solver Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial21/tutorial.html Configures a supervised learning problem using the SupervisedProblem class with input and target data. It then initializes a SupervisedSolver, passing the defined problem and the constructed Neural Operator model, preparing the system for training. ```python # making the problem problem = SupervisedProblem(input, target) # making the solver solver = SupervisedSolver(problem, model, use_lt=False) ``` -------------------------------- ### Install PINA for Google Colab Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial17/tutorial.html This code snippet checks if the environment is Google Colab and installs the PINA library with tutorial dependencies if it is. This ensures the necessary packages are available for running the tutorial on Colab. ```python import warnings import torch import matplotlib.pyplot as plt warnings.filterwarnings("ignore") from pina import Condition, LabelTensor from pina.problem import AbstractProblem from pina.geometry import CartesianDomain ``` -------------------------------- ### Check and Install PINA in Google Colab Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial21/tutorial.html This code block checks if the current environment is Google Colab. If it is, it proceeds to install the 'pina-mathlab[tutorial]' package using pip, ensuring the necessary components for tutorials are available. ```python ## routine needed to run the notebook on Google Colab try: import google.colab IN_COLAB = True except: IN_COLAB = False if IN_COLAB: !pip install "pina-mathlab[tutorial]" ``` -------------------------------- ### Handle HTTP Requests Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial3/tutorial.html This snippet demonstrates how to handle HTTP requests. It sets up request handlers for specific routes and defines the logic to be executed when those routes are accessed. ```Unknown ZGhqZPn66zzjpLO3fu1KOPPqru3bvr+++/V506darchnAjNwCEGrnh3NwIJjMkcgNA5aqSG/VPr6/f9/4ehlb9IdjcKC0t1V133aXzzz9f7du3r3C8s846S1OnTlXHjh21f/9+PffcczrvvPP0ww8/BLVe/GHJp/WNGjXKc8d66Xhlr1mzZjrvT/erWrWqH0ECYG2xP/3sc/ix0mIt3vNm0DvKxcXF2r27VIuXNVTt2uE5KnrokKGeGbu0bds2JSQkeIaH4ui3v/r27ev5/44dOyojI0PNmzfXu+++qyFDhkSsHZFEbgDuRm5UDbnxR25c8cHVql4r1sSWATDT0cPF+vel71YpN37f+7uu+GCgqteqHuLWHXf08FH9+9JZQeXG8OHD9f3335/yvoLdunVTt27dPH+fd955atOmjV599VU9/vjjwTe+EmEvTqWkpKiwsNBrWGFhoRISEio8klHR6WjVqsWpWrXw3iEegPmqRVe+U1jV0+1r145S7TrBnaZ7asePrickJHiFRagEs02tW7euWrVqpfXr14e8PeFAbgAIFLlRMafnRjDLJ1WcG9VrxSq2NsUpwO2qmhvVa1UP+7Yk0NwYMWK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v3FllJ9fNuOktAD ``` -------------------------------- ### Get Current Year Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves the current year from a Date object. ```javascript function GetCurrentYear(date) { return date.getFullYear(); } ``` -------------------------------- ### Get Current Millisecond Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves the current millisecond (0-999) from a Date object. ```javascript function GetCurrentMillisecond(date) { return date.getMilliseconds(); } ``` -------------------------------- ### Get Current Second Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves the current second (0-59) from a Date object. ```javascript function GetCurrentSecond(date) { return date.getSeconds(); } ``` -------------------------------- ### Import PINA modules and utilities Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial18/tutorial.html Imports necessary libraries and modules from PINA, including Trainer, solver interfaces, FeedForward model, and SupervisedProblem. It also sets up warnings and plotting utilities. ```python import warnings import torch import matplotlib.pyplot as plt warnings.filterwarnings("ignore") from pina import Trainer from pina.solver import SingleSolverInterface, SupervisedSolverInterface from pina.model import FeedForward from pina.problem.zoo import SupervisedProblem ``` -------------------------------- ### Get Current Minute Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves the current minute (0-59) from a Date object. ```javascript function GetCurrentMinute(date) { return date.getMinutes(); } ``` -------------------------------- ### Instantiate and Inspect AdvectionProblem Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial16/tutorial.html Demonstrates how to import and instantiate the AdvectionProblem from the PINA library. It also prints information about the problem's conditions, inheritance, and domain types. ```python from pina.problem.zoo import AdvectionProblem # defining the problem problem = AdvectionProblem() # some infos print( f"The {problem.__class__.__name__} has {len(problem.conditions)} " f"conditions with names {list(problem.conditions.keys())} \n" "The problem inherits from " f"{([cls.__name__ for cls in problem.__class__.__bases__])} \n" f"and the domains are of type {type(problem.domains['t0']).__name__}" ) ``` -------------------------------- ### Get Current Hour Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves the current hour (0-23) from a Date object. ```javascript function GetCurrentHour(date) { return date.getHours(); } ``` -------------------------------- ### Import Core PINA and Utility Libraries Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial8/tutorial.html Imports essential libraries for the tutorial, including PINA's core components like Trainer, FeedForward models, SupervisedSolver, TorchOptimizer, and specific blocks like PODBlock and RBFBlock. It also imports standard Python libraries for plotting and numerical operations. ```python import matplotlib import matplotlib.pyplot as plt import torch import numpy as np import warnings from pina import Trainer from pina.model import FeedForward from pina.solver import SupervisedSolver from pina.optim import TorchOptimizer from pina.problem.zoo import SupervisedProblem from pina.model.block import PODBlock, RBFBlock warnings.filterwarnings("ignore") ``` -------------------------------- ### Get Current Month Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves the current month (0-indexed) from a Date object. ```javascript function GetCurrentMonth(date) { return date.getMonth(); } ``` -------------------------------- ### Array Initialization in C++ Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial3/tutorial.html Shows different ways to initialize arrays in C++, including direct initialization and using loops. ```cpp #include int main() { // Direct initialization int arr1[5] = {10, 20, 30, 40, 50}; // Initialization with a loop int arr2[3]; for (int i = 0; i < 3; ++i) { arr2[i] = (i + 1) * 100; } std::cout << "arr1[2]: " << arr1[2] << std::endl; std::cout << "arr2[1]: " << arr2[1] << std::endl; return 0; } ``` -------------------------------- ### Get String Length Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Returns the number of characters in a string. This is a fundamental string property. ```javascript function GetStringLength(str) { return str.length; } ``` -------------------------------- ### Configure and Train PINN Solver Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial1/tutorial.html Sets up and trains a PINN solver using the Trainer class. It configures training parameters such as maximum epochs, logging, callbacks, accelerator, and data split ratios. Dependencies include the Trainer and MetricTracker from PINA. ```python from pina.callbacks import MetricTracker from pina.trainer import Trainer # create the trainer trainer = Trainer( solver=pinn, # The PINN solver to be used for training max_epochs=1500, # Maximum number of training epochs logger=True, # Enables logging (default logger is CSVLogger) callbacks=[MetricTracker()], # Tracks training metrics using MetricTracker accelerator="cpu", # Specifies the computing device ("cpu", "gpu", ...) train_size=1.0, # Fraction of the dataset used for training (100%) test_size=0.0, # Fraction of the dataset used for testing (0%) val_size=0.0, # Fraction of the dataset used for validation (0%) enable_model_summary=False, # Disables model summary printing ) # train trainer.train() ``` -------------------------------- ### Get Object Values Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves an array of a given object's own enumerable property values. ```javascript function GetObjectValues(obj) { return Object.values(obj); } ``` -------------------------------- ### Get Current Day of Month Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves the current day of the month (1-indexed) from a Date object. ```javascript function GetCurrentDayOfMonth(date) { return date.getDate(); } ``` -------------------------------- ### Load and Inspect PyTorch Geometric QM7b Dataset Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial19/tutorial.html Demonstrates loading the QM7b dataset using PyTorch Geometric and inspecting the first data object within the shuffled dataset. This shows how to integrate external graph datasets into a workflow. ```python from torch_geometric.datasets import QM7b dataset = QM7b(root="./tutorial_logs").shuffle() # save the dataset input_ = [data for data in dataset] input_[0] ``` -------------------------------- ### Get Object Keys Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves an array of a given object's own enumerable property names (keys). ```javascript function GetObjectKeys(obj) { return Object.keys(obj); } ``` -------------------------------- ### Get Array Length Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Returns the number of elements in an array. This is a basic property of array data structures. ```javascript function GetArrayLength(arr) { return arr.length; } ``` -------------------------------- ### Initialize and Train PINN Solver Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial17/tutorial.html Sets up a PINN solver and trains it for a specified number of epochs. It uses a MetricTracker callback to monitor training progress. The trainer can utilize accelerators like 'cpu' or 'gpu'. Model summary can be enabled or disabled. ```python from pina.solver import PINN from pina.callback import MetricTracker # define the solver solver = PINN(poisson_problem, model) # define trainer trainer = Trainer( solver, max_epochs=1500, callbacks=[MetricTracker()], accelerator="cpu", enable_model_summary=False, ) # train trainer.train() ``` -------------------------------- ### Get Current Date and Time Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves the current date and time. This is often used for logging or timestamping. ```javascript function GetCurrentDateTime() { return new Date(); } ``` -------------------------------- ### HTML Widget Configuration (Jupyter) Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial11/tutorial.html Configuration for an HTML widget displaying training progress, including model name, module, version, and state. The state defines the HTML content with epoch and iteration details. ```json { "model_name": "HTMLModel", "model_module": "@jupyter-widgets\/controls", "model_module_version": "2.0.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets\/controls", "_model_module_version": "2.0.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets\/controls", "_view_module_version": "2.0.0", "_view_name": "HTMLView", "description": "", "description_allow_html": false, "layout": "IPY_MODEL_702d1a2da9eb4056907f2aee81439764", "placeholder": "\u200b", "style": "IPY_MODEL_5201f9f136b54b8fbaf849d085b50021", "tabbable": null, "tooltip": null, "value": "Epoch\u200799:\u2007100%" } } ``` -------------------------------- ### Create a Supervised Learning Problem Instance Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial15/tutorial.html Initializes a SupervisedProblem object from the PINA library, using the prepared input graph data and normalized target properties derived from the QM9 dataset. ```python # build the problem problem = SupervisedProblem(input_=input_, output_=target_) ``` -------------------------------- ### File Reading in Python Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial3/tutorial.html A Python example for reading content from a file. This is essential for data input and persistence. ```python try: with open('data.txt', 'r') as f: content = f.read() print(content) except FileNotFoundError: print('File not found.') ``` -------------------------------- ### Get Day of Week Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves the day of the week (0 for Sunday, 1 for Monday, etc.) from a Date object. ```javascript function GetDayOfWeek(date) { return date.getDay(); } ``` -------------------------------- ### Initialize PINA Trainer with default settings Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial11/tutorial.html Initializes the PINA Trainer by passing the configured SupervisedSolver. The Trainer automatically selects the best available accelerator (TPU, IPU, HPU, GPU, MPS, CPU) by default. ```python trainer = Trainer(solver=solver) ``` -------------------------------- ### Get Object Entries Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial9/tutorial.html Retrieves an array of a given object's own enumerable string-keyed property [key, value] pairs. ```javascript function GetObjectEntries(obj) { return Object.entries(obj); } ``` -------------------------------- ### HTML Widget Model Configuration Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial11/tutorial.html Defines the configuration for an HTML widget, including its model name, module, and version. It specifies the state of the HTML content, such as descriptions and associated layout and style models. ```json { "model_name": "HTMLModel", "model_module": "@jupyter-widgets\/controls", "model_module_version": "2.0.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets\/controls", "_model_module_version": "2.0.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets\/controls", "_view_module_version": "2.0.0", "_view_name": "HTMLView", "description": "", "description_allow_html": false, "layout": "IPY_MODEL_6c2ae8a8b0d5471098c9194185b8e202", "placeholder": "\u200b", "style": "IPY_MODEL_d4617c3ffb8947b8b42749c571db47b9", "tabbable": null, "tooltip": null, "value": "\u20071\/1\u2007[00:00<00:00,\u200798.26it\/s,\u2007v_num=1,\u2007data_loss=124.0,\u2007train_loss=124.0]" } } ``` -------------------------------- ### Get Numeric Month Name (JavaScript) Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial13/tutorial.html Retrieves the full English name of a month given its numeric index (0-11). ```javascript function getNumericMonthName(month) { const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; return monthNames[month]; } ``` -------------------------------- ### Handle generic operations Source: https://github.com/mathlab/pina/blob/master/docs/source/tutorials/tutorial3/tutorial.html This snippet demonstrates how to handle generic operations. It sets up handlers for performing common mathlab-specific operations. It defines the logic to be executed when those generic operations are initiated. ```Unknown CiAgICAgICAgAABmoDhlAit3MBAcK3c2rPp9A+A/q/6OrbrdswNyAwAA4A9c1gfL7hzbEZdtAHADciN0yA0AAADOnJIU2VPKrXY0kg5GeFhtvVrtewfYHbmBULPaerXa9w4AADgbxSmXsvLlBE5htXUcqY4G9w8BnMlq2zQncus6JjcAAADFqQiyylFIN+74mon1DSBY5IY7WWV9W+X7BwAAnI/ilMtYZYfXbayy3uloAPZhld+rVbZfbmOV9W6V7yEAAHA2bogeIWbv3FllJ9fNuOktAD ```