Skip to content
sleepKIT
User guide
HELIA

Configuration Parameters

For each mode, common configuration parameters, TaskParams, are required to run the task. These parameters are used to define the task, datasets, model, and other settings. Rather than defining separate configuration files for each mode, a single configuration object is used to simplify configuration files and heavy re-use of parameters between modes.

Quantization parameters define the quantization-aware training (QAT) and post-training quantization (PTQ) settings. This is used for modes: train, evaluate, export, and demo.

ArgumentTypeOpt/ReqDefaultDescription
enabledboolOptionalFalseEnable quantization
qatboolOptionalFalseEnable quantization aware training (QAT)
formatLiteral[“int8”, “int16”, “float16”]Optionalint8Quantization mode
io_typestrOptionalint8I/O type
conversionLiteral[“keras”, “tflite”]OptionalkerasConversion method
debugboolOptionalFalseDebug quantization
fallbackboolOptionalFalseFallback to float32

Named parameters are used to provide custom parameters for a given object or callable where parameter types are not known ahead of time. For example, a dataset, ‘CustomDataset’, may require custom parameters such as ‘path’, ‘label’, ‘sampling_rate’, etc. When a task loads the dataset using name, the task will then unpack the custom parameters and pass them to the dataset initializer.

ArgumentTypeOpt/ReqDefaultDescription
namestrRequiredNamed parameters name
paramsdict[str, Any]Optional{}Named parameters
Python example
import sleepkit as sk
class CustomDataset(sk.Dataset):
def __init__(self, a: int = 1, b: int = 2) -> None:
self.a = a
self.b = b
sk.DatasetFactory.register("custom", CustomDataset)
params = sk.TaskParams(
datasets=[
sk.NamedParams(
name="custom",
params=dict(a=1, b=2)
)
]
)
ArgumentTypeOpt/ReqDefaultDescription
namestrRequiredfeatureFeature set name
sampling_ratefloatOptional250Target sampling rate (Hz)
frame_sizeintOptional1250Frame size in samples
loaderstrOptionalhdf5Data loader
feat_keystrOptionalfeaturesFeature key
label_keystrOptionallabelsLabel key
mask_keystrOptionalmaskMask key
feat_colslist[str]|NoneOptionalNoneFeature columns
save_pathPathOptionaltempfile.gettempdirSave path
paramsdict[str, Any]Optional{}Feature Parameters

These parameters are supplied to a Task when running a given mode such as train, evaluate, export, or demo. A single configuration object is used to simplify configuration files and heavy re-use of parameters between modes.

ArgumentTypeOpt/ReqDefaultDescriptionMode
namestrRequiredexperimentExperiment nameAll
projectstrRequiredsleepkitProject nameAll
job_dirPathOptionaltempfile.gettempdirJob output directoryAll
datasetslist[NamedParams]Optional[]DatasetsAll
dataset_weightslist[float]|NoneOptionalNoneDataset weightsAll
force_downloadboolOptionalFalseForce download dataset- overriding existing filesdownload
featureFeatureParamsOptional{}Feature configurationfeature
sampling_ratefloatOptional250Target sampling rate (Hz)feature
frame_sizeintOptional1250Frame size in samplesfeature
samples_per_subjectint|list[int]Optional1000Number train samples per subjectAll
val_samples_per_subjectint|list[int]Optional1000Number validation samples per subjectAll
test_samples_per_subjectint|list[int]Optional1000Number test samples per subjectAll
preprocesseslist[NamedParams]Optional[]PreprocessesAll
augmentationslist[NamedParams]Optional[]AugmentationsAll
num_classesintOptional1# of classesAll
class_mapdict[int, int]Optional{1: 1}Class/label mappingAll
class_nameslist[str]|NoneOptionalNoneClass namesAll
train_subjectsfloat|NoneOptionalNone# or proportion of subjects for trainingAll
val_subjectsfloat|NoneOptionalNone# or proportion of subjects for validationAll
test_subjectsfloat|NoneOptionalNone# or proportion of subjects for testingAll
val_filePath|NoneOptionalNonePath to load/store TFDS validation dataAll
test_filePath|NoneOptionalNonePath to load/store TFDS test dataAll
val_sizeint|NoneOptionalNoneNumber of samples for validationAll
test_sizeintOptional10000# samples for testingAll
resumeboolOptionalFalseResume trainingtrain
architectureNamedParams|NoneOptionalNoneCustom model architecturetrain
model_filePath|NoneOptionalNonePath to load/save model file (.keras)All
use_logitsboolOptionalTrueUse logits output or softmaxAll
weights_filePath|NoneOptionalNonePath to a checkpoint weights to load/saveAll
quantizationQuantizationParamsOptional{}Quantization parameterstrain, evaluate, export, demo
lr_ratefloatOptional1e-3Learning ratetrain
lr_cyclesintOptional3Number of learning rate cyclestrain
lr_decayfloatOptional0.9Learning rate decaytrain
label_smoothingfloatOptional0Label smoothingtrain
batch_sizeintOptional32Batch sizetrain
buffer_sizeintOptional100Buffer cache sizetrain
epochsintOptional50Number of epochstrain
steps_per_epochintOptional10Number of steps per epochtrain
val_steps_per_epochintOptional10Number of validation stepstrain
val_metricLiteral[“loss”, “acc”, “f1”]OptionallossPerformance metrictrain
class_weightsLiteral[“balanced”, “fixed”]OptionalfixedClass weightstrain
thresholdfloat|NoneOptionalNoneModel output thresholdevaluate
test_metricLiteral[“loss”, “acc”, “f1”]OptionalaccTest metricevaluate
test_metric_thresholdfloat|NoneOptional0.98Validation metric thresholdevaluate
tflm_var_namestrOptionalg_modelTFLite Micro C variable nameexport
tflm_filePath|NoneOptionalNonePath to copy TFLM header file (e.g. ./model_buffer.h)export
backendstrOptionalpcBackenddemo
demo_sizeint|NoneOptional1000# samples for demodemo
display_reportboolOptionalTrueDisplay reportdemo
seedint|NoneOptionalNoneRandom state seedAll
num_workersintOptionalos.cpu_count() or 1Number of workers for parallel processingAll
verboseintOptional1Verbosity levelAll