learnergy.core

Core is the core. Essentially, it is the parent of everything. You should find parent classes defining the basic of our structure. They should provide variables and methods that will help to construct other modules.

A core package for all common learnergy modules.

class learnergy.core.Dataset(data: numpy.array, targets: numpy.array, transform: Optional[callable] = None, show_log: Optional[xmlrpc.client.Boolean] = True)

Bases: torch.utils.data.Dataset

A custom dataset class, inherited from PyTorch’s dataset.

__getitem__(self, idx: int)

A private method that will be the base for PyTorch’s iterator getting a new sample.

Parameters

idx – The idx of desired sample.

Returns

Data and label tensors.

Return type

(Tuple[torch.Tensor, torch.Tensor])

__init__(self, data: numpy.array, targets: numpy.array, transform: Optional[callable] = None, show_log: Optional[xmlrpc.client.Boolean] = True)

Initialization method.

Parameters
  • data – An n-dimensional array containing the data.

  • targets – An 1-dimensional array containing the data’s labels.

  • transform – Optional transform to be applied over a sample.

__len__(self)

A private method that will be the base for PyTorch’s iterator getting dataset’s length.

Returns

Length of dataset.

Return type

(int)

property data(self)

An n-dimensional array containing the data.

property targets(self)

An 1-dimensional array containing the data’s labels.

property transform(self)

Optional transform to be applied over a sample.

class learnergy.core.Model(use_gpu: Optional[bool] = False)

Bases: torch.nn.Module

The Model class is the basis for any custom model.

One can configure, if necessary, different properties or methods that can be used throughout all childs.

__init__(self, use_gpu: Optional[bool] = False)

Initialization method.

Parameters

use_gpu – Whether GPU should be used or not.

property device(self)

Indicates which device is being used for computation.

dump(self, **kwargs)

Dumps any amount of keyword documents to lists in the history property.

property history(self)

Dictionary containing historical values from the model.