secml.parallel

parfor

secml.parallel.parfor.parfor(task, processes, args)[source]

Parallel For.

Applies a function task to each argument in args, using a pool of concurrent processes.

Parameters
taskfunction

Function object that should process each element in args.

processesint

Maximum number of concurrent processes to be used in the pool. If higher than multiprocessing.cpu_count(), all processor’s cores will be used.

argsany

Iterable object, where each element is an argument for task.

Returns
outiterable

Iterable object containing the output of task(arg) for each arg in args.

secml.parallel.parfor.parfor2(task, n_reps, processes, *args)[source]

Parallel For.

Run function task using each argument in args as input, using a pool of concurrent processes. The task should take as first input the index of parfor iteration.

Parameters
taskfunction

Function object that should process each element in args.

n_repsint

Number of times the task should be run.

processesint

Maximum number of concurrent processes to be used in the pool. If higher than multiprocessing.cpu_count(), all processor’s cores will be used.

argsany, optional

Tuple with input arguments for task.

Returns
outlist

List with iteration output, sorted (rep1, rep2, …, repN).