class TopoDataset[source]
TopoDataset(dataset:list=[],name:str=None,verbose:bool=True) ::Dataset
A class for the generation of datasets. TopoDataset inherits from torch.utils.data.Dataset, so all functionalities from PyTorch are also available here.
| Type | Default | Details | |
|---|---|---|---|
dataset |
list |
None |
A list containing either only problems or tuples (problem, gt_solution) of problems and corresponding ground truth solutions. By default, dataset=[], so the dataset is empty. However, it can still be changed later via TopoDataset.dataset=.... |
name |
str |
None |
The name of the dataset. |
verbose |
bool |
True |
Whether to give the user feedback on the progress. |
TopoDataset.__getitem__[source]
TopoDataset.__getitem__(idx:int)
Returns the tuple (problem, gt_solution) for index idx.
| Type | Default | Details | |
|---|---|---|---|
idx |
int |
The index for which (problem, gt_solution) should be returned. |
TopoDataset.get_samples[source]
TopoDataset.get_samples(n:int=-1,shuffle:bool=True,seed:int=42)
Returns a tuple of lists (problems, gt_solutions) of length n.
| Type | Default | Details | |
|---|---|---|---|
n |
int |
-1 |
The number of samples that should be returned. The default choice n=-1 returns all samples from the dataset. |
shuffle |
bool |
True |
Whether to take the samples from a shuffled dataset. If False, then the first samples from the dataset are taken. |
seed |
int |
42 |
The random seed for the shuffling |
TopoDataset.get_problems[source]
TopoDataset.get_problems(n:int=-1,shuffle:bool=True,seed:int=42)
Returns a list of length n which contains problems from the dataset.
| Type | Default | Details | |
|---|---|---|---|
n |
int |
-1 |
The number of problems that should be returned. The default choice n=-1 returns all problems from the dataset. |
shuffle |
bool |
True |
Whether to take the problems from a shuffled dataset. If False, then the first problems from the dataset are taken. |
seed |
int |
42 |
The random seed for the shuffling |
TopoDataset.get_gt_solutions[source]
TopoDataset.get_gt_solutions(n:int=-1,shuffle:bool=True,seed:int=42)
Returns a list of length n which contains ground truth solutions from the dataset.
| Type | Default | Details | |
|---|---|---|---|
n |
int |
-1 |
The number of ground truth solutions that should be returned. The default choice n=-1 returns all solutions from the dataset. |
shuffle |
bool |
True |
Whether to take the solutions from a shuffled dataset. If False, then the first solutions from the dataset are taken. |
seed |
int |
42 |
The random seed for the shuffling |
TopoDataset.get_subset[source]
TopoDataset.get_subset(size:int,shuffle=True,seed=42,invert_order=False)
Returns a new dl4to.dataset.TopoDataset object with a subset of size samples from the original dataset.
| Type | Default | Details | |
|---|---|---|---|
size |
int |
The size of the returned topo dataset. | |
shuffle |
bool |
True |
Whether to take the samples from a shuffled dataset. If False, then the first samples from the dataset are taken. |
seed |
int |
42 |
The random seed for the shuffling |
invert_order |
bool |
False |
Whether the last samples should be taken (instead of the first samples). Only has an effect if shuffle=False. |
TopoDataset.__add__[source]
TopoDataset.__add__(dataset:Union[ForwardRef('dl4to.dataset.TopoDataset'),list])
Adding up two datasets results in a new dataset object that contains the samples from both original datasets.
| Type | Default | Details | |
|---|---|---|---|
dataset |
typing.Union[ForwardRef('dl4to.dataset.TopoDataset'), list] |
The dataset that is added to this one. If dataset is a list, then the samples in the list are added to the current dataset. |
class CombinedTopoDataset[source]
CombinedTopoDataset(dataset1:dl4to.dataset.TopoDataset,dataset2:dl4to.dataset.TopoDataset) ::TopoDataset
A class that results from the summation of two topo datasets.
| Type | Default | Details | |
|---|---|---|---|
dataset1 |
dl4to.dataset.TopoDataset |
The first dataset of the summation. | |
dataset2 |
dl4to.dataset.TopoDataset |
The second dataset of the summation. |
CombinedTopoDataset.get_subset[source]
CombinedTopoDataset.get_subset(size:int,shuffle:bool=True,seed:int=42,balanced:bool=True)
Returns an instance of dl4to.dataset.TopoDataset with a subset of size samples from the original dataset.
| Type | Default | Details | |
|---|---|---|---|
size |
int |
The size of the returned topo dataset. | |
shuffle |
bool |
True |
Whether the dataset should be shuffled. If False, then the first samples from both datasets are taken. |
seed |
int |
42 |
The random seed for the shuffling. |
balanced |
bool |
True |
Whether the ratio between dataset1 and dataset2 should be maintained in the subset. |