torch
TorchDataset(inputs, outputs=None)
Bases: Dataset[tuple[Tensor, Tensor]]
Dataset for PyTorch.
Initialize the TorchDataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs
|
DataFrame
|
The input data. |
required |
outputs
|
DataFrame | None
|
The output data. Defaults to None. |
None
|
Source code in src/flowcean/torch/dataset.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
__len__()
Return the length of the dataset.
Source code in src/flowcean/torch/dataset.py
24 25 26 |
|
__getitem__(item)
Return the item at the given index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
int
|
The index of the item to return. |
required |
Returns:
Type | Description |
---|---|
tuple[Tensor, Tensor]
|
The inputs and outputs at the given index. |
Source code in src/flowcean/torch/dataset.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
LightningLearner(module, num_workers=None, batch_size=32, max_epochs=100)
Bases: SupervisedLearner
A learner that uses PyTorch Lightning.
Initialize the learner.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module
|
LightningModule
|
The PyTorch Lightning module. |
required |
num_workers
|
int | None
|
The number of workers to use for the DataLoader. |
None
|
batch_size
|
int
|
The batch size to use for training. |
32
|
max_epochs
|
int
|
The maximum number of epochs to train for. |
100
|
Source code in src/flowcean/torch/lightning_learner.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
MultilayerPerceptron(learning_rate, input_size, output_size, hidden_dimensions=None)
Bases: LightningModule
A multilayer perceptron.
Initialize the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
learning_rate
|
float
|
The learning rate. |
required |
input_size
|
int
|
The size of the input. |
required |
output_size
|
int
|
The size of the output. |
required |
hidden_dimensions
|
list[int] | None
|
The dimensions of the hidden layers. |
None
|
Source code in src/flowcean/torch/lightning_learner.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
LinearRegression(input_size, output_size, learning_rate=0.001, loss=None)
Bases: SupervisedIncrementalLearner
Linear regression learner.
Initialize the learner.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_size
|
int
|
The size of the input. |
required |
output_size
|
int
|
The size of the output. |
required |
learning_rate
|
float
|
The learning rate. |
0.001
|
loss
|
Module | None
|
The loss function. |
None
|
Source code in src/flowcean/torch/linear_regression.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
PyTorchModel(module, output_names, batch_size=32, num_workers=1)
Bases: Model
PyTorch model wrapper.
Initialize the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module
|
Module
|
The PyTorch module. |
required |
output_names
|
list[str]
|
The names of the output columns. |
required |
batch_size
|
int
|
The batch size to use for predictions. |
32
|
num_workers
|
int
|
The number of workers to use for the DataLoader. |
1
|
Source code in src/flowcean/torch/model.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|