peal.data.custom_datasets.OnlySparseNumbersDataset¶
- class peal.data.custom_datasets.OnlySparseNumbersDataset[source]¶
Bases:
Image2MixedDatasetSynthetic images showing a 2x4 grid of numbers and nothing else.
OnlySparseNumbersDatasetGeneratorwrites the dataset on first use. Itsdata.csvstores one row of 8 slot columns per image, each holding the number drawn in that slot or-1; this class expands that row into a binary vector over allconfig.output_split(default 1000) possible numbers, so a classifier can be trained on “does number k appear”. Targets are therefore selected by attribute names of the form"Num<k>".- Parameters:
config (
DataConfig) – Usesdataset_path,output_split,output_sizeandconfounding_factors.**kwargs – Forwarded to the generator and to
Image2MixedDataset.
- Variables:
attributes (
listofstr) –Num0 ... Num<output_split - 1>, the expanded label vector;attributes_positive/attributes_negativeare its phrasings.
Notes
Since
attributesis the expanded vector whiledata[key]is still the raw slot row, the base-class helpers that index the row by attribute position are overridden below.Methods
Restrict
keysto the samples of one class of the selected number.Subsample
keysto the proportions inconfig.class_ratios.Attributes
- __init__(config, **kwargs)[source]¶
Generate the dataset if missing and build the expanded attribute names.
- Parameters:
config (DataConfig)