PyTorch Helper Functions
Ver. 3.0.2 (2023-03-10)
This a helper module for supervised learning models using PyTorch.
- class mlpro.sl.pool.afct.pytorch.PyTorchIOElement(p_input: Tensor, p_output: Tensor)
Bases:
BufferElement
This class provides a buffer element for PyTorch based SLNetwork.
- class mlpro.sl.pool.afct.pytorch.PyTorchBuffer(p_size: int = 1, p_test_data: float = 0.3, p_batch_size: int = 100, p_seed: int = 1)
Bases:
Buffer
,Dataset
This class provides buffer functionalities for PyTorch based SLNetwork and also using several built-in PyTorch functionalities.
- Parameters:
p_size (int) – the buffer size. Default = 1.
p_test_data (float) – the proportion of testing data within the sampled data. Default = 0.3.
p_batch_size (int) – the batch size for a sample. Default = 100.
p_seed (int) – the seeding for randomizer in the buffer, optional. Default = 1.
- add_element(p_elem: BufferElement)
This method has a functionality to add an element to the buffer.
- Parameters:
p_elem (BufferElement) – an element of the buffer
- get_internal_counter() int
This method has a functionality to get the number of elements being added to the buffer.
- sampling()
This method has a functionality to sample from the buffer using built-in PyTorch functionalities.
- class mlpro.sl.pool.afct.pytorch.PyTorchHelperFunctions
Bases:
object
PyTorch Helper Functions in MLPro-SL.
- input_preproc(p_input: Element) Tensor
This method has a functionality to transform input data in the form of Element to torch.Tensor for pre-processing.
- Parameters:
p_input (Element) – Input data in the form of Element.
- Returns:
input – Input data in the form of torch.Tensor.
- Return type:
torch.Tensor
- output_preproc(p_output: Element) Tensor
This method has a functionality to transform output data in the form of Element to torch.Tensor for pre-processing.
- Parameters:
p_output (Element) – Output data in the form of Element.
- Returns:
output – Output data in the form of torch.Tensor.
- Return type:
torch.Tensor
- output_postproc(p_output: Tensor) list
This method has a functionality to transform output data in the form of torch.Tensor to a list for post-processing.
- Parameters:
p_output (torch.Tensor) – Output data in the form of torch.Tensor.
- Returns:
output – Output data in the form of list.
- Return type:
list