# Table of Contents - [Table of Contents](#table-of-contents) - [main](#main) - [:orange\[PINN\]](#orangepinn) - [PINN.pinns](#pinnpinns) - [PINNd\_p Objects](#pinnd_p-objects) - [PINNhd\_ma Objects](#pinnhd_ma-objects) - [PINNT\_ma Objects](#pinnt_ma-objects) - [:orange\[utils\]](#orangeutils) - [utils.test](#utilstest) - [utils.dataset\_loader](#utilsdataset_loader) - [get\_dataset](#get_dataset) - [utils.ndgan](#utilsndgan) - [DCGAN Objects](#dcgan-objects) - [define\_discriminator](#define_discriminator) - [generate\_latent\_points](#generate_latent_points) - [define\_gan](#define_gan) - [summarize\_performance](#summarize_performance) - [train\_gan](#train_gan) - [utils.data\_augmentation](#utilsdata_augmentation) - [dataset Objects](#dataset-objects) - [\_\_init\_\_](#__init__) - [:orange\[nets\]](#orangenets) - [nets.envs](#netsenvs) - [SCI Objects](#sci-objects) - [data\_flow](#data_flow) - [init\_seed](#init_seed) - [compile](#compile) - [train](#train) - [inference](#inference) - [RCI Objects](#rci-objects) - [data\_flow](#data_flow-1) - [compile](#compile-1) - [nets.dense](#netsdense) - [Net Objects](#net-objects) - [\_\_init\_\_](#__init__-1) - [nets.design](#netsdesign) - [B\_field\_norm](#b_field_norm) - [nets.deep\_dense](#netsdeep_dense) - [dmodel Objects](#dmodel-objects) - [\_\_init\_\_](#__init__-2) # main # :orange[PINN] ## PINN.pinns ## PINNd\_p Objects ```python class PINNd_p(nn.Module) ``` $d \mapsto P$ ## PINNhd\_ma Objects ```python class PINNhd_ma(nn.Module) ``` $h,d \mapsto m_a $ ## PINNT\_ma Objects ```python class PINNT_ma(nn.Module) ``` $ m_a, U \mapsto T$ --- # :orange[utils] ## utils.test ## utils.dataset\_loader #### get\_dataset ```python def get_dataset(raw: bool = False, sample_size: int = 1000, name: str = 'dataset.pkl', source: str = 'dataset.csv', boundary_conditions: list = None) -> _pickle ``` Gets augmented dataset **Arguments**: - `raw` _bool, optional_ - either to use source data or augmented. Defaults to False. - `sample_size` _int, optional_ - sample size. Defaults to 1000. - `name` _str, optional_ - name of wanted dataset. Defaults to 'dataset.pkl'. - `boundary_conditions` _list,optional_ - y1,y2,x1,x2. **Returns**: - `_pickle` - pickle buffer ## utils.ndgan ### DCGAN Objects ```python class DCGAN() ``` #### define\_discriminator ```python def define_discriminator(inputs=8) ``` function to return the compiled discriminator model #### generate\_latent\_points ```python def generate_latent_points(latent_dim, n) ``` generate points in latent space as input for the generator #### define\_gan ```python def define_gan(generator, discriminator) ``` define the combined generator and discriminator model #### summarize\_performance ```python def summarize_performance(epoch, generator, discriminator, latent_dim, n=200) ``` evaluate the discriminator and plot real and fake samples #### train\_gan ```python def train_gan(g_model, d_model, gan_model, latent_dim, num_epochs=2500, num_eval=2500, batch_size=2) ``` function to train gan model ## utils.data\_augmentation ## dataset Objects ```python class dataset() ``` Creates dataset from input source #### \_\_init\_\_ ```python def __init__(number_samples: int, name: str, source: str, boundary_conditions: list = None) ``` _summary_ **Arguments**: - `number_samples` _int_ - _description_ - `name` _str_ - _description_ - `source` _str_ - _description_ - `boundary_conditions` _list_ - y1,y2,x1,x2 # :orange[nets] ## nets.envs ### SCI Objects ```python class SCI() ``` #### data\_flow ```python def data_flow(columns_idx: tuple = (1, 3, 3, 5), idx: tuple = None, split_idx: int = 800) -> torch.utils.data.DataLoader ``` Data prep pipeline **Arguments**: - `columns_idx` _tuple, optional_ - Columns to be selected (sliced 1:2 3:4) for feature fitting. Defaults to (1,3,3,5). - `idx` _tuple, optional_ - 2|3 indexes to be selected for feature fitting. Defaults to None. Use either idx or columns_idx (for F:R->R idx, for F:R->R2 columns_idx) split_idx (int) : Index to split for training **Returns**: - `torch.utils.data.DataLoader` - Torch native dataloader #### init\_seed ```python def init_seed(seed) ``` Initializes seed for torch optional() #### compile ```python def compile(columns: tuple = None, idx: tuple = None, optim: torch.optim = torch.optim.AdamW, loss: nn = nn.L1Loss, model: nn.Module = dmodel, custom: bool = False) -> None ``` Builds model, loss, optimizer. Has defaults **Arguments**: - `columns` _tuple, optional_ - Columns to be selected for feature fitting. Defaults to (1,3,3,5). optim - torch Optimizer loss - torch Loss function (nn) #### train ```python def train(epochs: int = 10) -> None ``` Train model If sklearn instance uses .fit() #### inference ```python def inference(X: tensor, model_name: str = None) -> np.ndarray ``` Inference of (pre-)trained model **Arguments**: - `X` _tensor_ - your data in domain of train **Returns**: - `np.ndarray` - predictions ### RCI Objects ```python class RCI(SCI) ``` #### data\_flow ```python def data_flow(columns_idx: tuple = (1, 3, 3, 5), idx: tuple = None, split_idx: int = 800) -> torch.utils.data.DataLoader ``` Data prep pipeline **Arguments**: - `columns_idx` _tuple, optional_ - Columns to be selected (sliced 1:2 3:4) for feature fitting. Defaults to (1,3,3,5). - `idx` _tuple, optional_ - 2|3 indexes to be selected for feature fitting. Defaults to None. Use either idx or columns_idx (for F:R->R idx, for F:R->R2 columns_idx) split_idx (int) : Index to split for training **Returns**: - `torch.utils.data.DataLoader` - Torch native dataloader #### compile ```python def compile(columns: tuple = None, idx: tuple = (3, 1), optim: torch.optim = torch.optim.AdamW, loss: nn = nn.L1Loss, model: nn.Module = PINNd_p, lr: float = 0.001) -> None ``` Builds model, loss, optimizer. Has defaults **Arguments**: - `columns` _tuple, optional_ - Columns to be selected for feature fitting. Defaults to None. - `idx` _tuple, optional_ - indexes to be selected Default (3,1) optim - torch Optimizer loss - torch Loss function (nn) ## nets.dense ### Net Objects ```python class Net(nn.Module) ``` 4 layer model, different activations and neurons count on layer #### \_\_init\_\_ ```python def __init__(input_dim: int = 2, hidden_dim: int = 200) ``` Init **Arguments**: - `input_dim` _int, optional_ - Defaults to 2. - `hidden_dim` _int, optional_ - Defaults to 200. ## nets.design #### B\_field\_norm ```python def B_field_norm(Bmax, L, k=16, plot=True) ``` Returns vec B_z **Arguments**: - `Bmax` _any_ - maximum B in thruster k - magnetic field profile number ## nets.deep\_dense ### dmodel Objects ```python class dmodel(nn.Module) ``` 4 layers Torch model. Relu activations, hidden layers are same size. #### \_\_init\_\_ ```python def __init__(in_features=1, hidden_features=200, out_features=1) ``` Init **Arguments**: - `in_features` _int, optional_ - Input features. Defaults to 1. - `hidden_features` _int, optional_ - Hidden dims. Defaults to 200. - `out_features` _int, optional_ - Output dims. Defaults to 1.