src.dienstleister.ml_training.pytorch_utils.py¶
- class MyDataset(df: DataFrame, prediction_columns: list)¶
Bases:
DatasetA custom dataset for the pytorch regression service.
- Parameters:
df (pd.DataFrame) – The dataframe containing the data.
prediction_columns (list) – The columns to be used as prediction targets.
- __getitem__(idx)¶
Get an item from the dataset.
- Parameters:
idx (int) – The index of the item to get.
- Returns:
The input and output data.
- Return type:
tuple
- __len__()¶
Return the length of the dataset.
- Returns:
The length of the dataset.
- Return type:
int
- class DemonstratorNeuralNet(input_dim, hidden_dim, output_dim, *args, **kwargs)¶
Bases:
ModuleA simple neural network for demonstration purposes.
- Parameters:
input_dim (int) – Dimension of the input layer.
hidden_dim (int) – Dimension of the hidden layers.
output_dim (int) – Dimension of the output layer.
args – Positional arguments passed to the superclass or internal use.
kwargs – Arbitrary keyword arguments, allowing for extensibility or forwarding to the superclass constructor or other components.
- forward(x)¶
Forward pass through the network.
- Parameters:
x – The input to the network.
- Returns:
The output of the network.
- Return type:
torch.Tensor