tomopt.optimisation.data package¶
Submodules¶
tomopt.optimisation.data.passives module¶
- class tomopt.optimisation.data.passives.AbsBlockPassiveGenerator(volume, block_size, block_size_max_half=None, materials=None)[source]¶
Bases:
AbsPassiveGeneratorAbstract base class for classes that generate new passive layouts which contain a single cuboid of material (block).
- The
_generate()method should be overridden to return: A function that provides an xy tensor for a given layer when called with its z position, length and width, and size.
An optional “target” value for the layout
The
generate()method will return only the layout function and no target Theget_data()method will return both the layout function and the targetThe block will be centred randomly in the volume, and can either be of fixed or random size.
- Parameters:
volume (
Volume) – Volume that the passive layout will be loaded intoblock_size (
Optional[Tuple[float,float,float]]) – if set, will generate blocks of the specified size and random orientation, otherwise will randomly set the size of the blocksblock_size_max_half (
Optional[bool]) – if True and block_size is None, the maximum size of blocks will be set to half the size of the passive volumematerials (
Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt
- The
- class tomopt.optimisation.data.passives.AbsPassiveGenerator(volume, materials=None)[source]¶
Bases:
objectAbstract base class for classes that generate new passive layouts.
- The
_generate()method should be overridden to return: A function that provides an xy tensor for a given layer when called with its z position, length and width, and size.
An optional “target” value for the layout
The
generate()method will return only the layout function and no target Theget_data()method will return both the layout function and the target- Parameters:
volume (
Volume) – Volume that the passive layout will be loaded intomaterials (
Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt
- The
- class tomopt.optimisation.data.passives.BlockPresentPassiveGenerator(volume, block_size, block_size_max_half=None, materials=None)[source]¶
Bases:
AbsBlockPassiveGeneratorGenerates new passive layouts which contain a single cuboid of material (block) of random material against a fixed background material. Blocks are always present, but can potentially be of the same material as the background. The target for the volumes is the X0 of the block material. The background material for the background will always be the zeroth material provided during initialisation.
The
generate()method will return only the layout function and no target Theget_data()method will return both the layout function and the targetThe block will be centred randomly in the volume, and can either be of fixed or random size.
- Parameters:
volume (
Volume) – Volume that the passive layout will be loaded intoblock_size (
Optional[Tuple[float,float,float]]) – if set, will generate blocks of the specified size and random orientation, otherwise will randomly set the size of the blocksblock_size_max_half (
Optional[bool]) – if True and block_size is None, the maximum size of blocks will be set to half the size of the passive volumematerials (
Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt
- class tomopt.optimisation.data.passives.PassiveYielder(passives, n_passives=None, shuffle=True)[source]¶
Bases:
object- Dataset class that can either:
Yield from a set of pre-specified passive-volume layouts, and optional targets Generate and yield random layouts and optional targets from a provided generator
- Parameters:
passives (
Union[List[Union[Tuple[Callable[[Tensor,Tensor,float],Tensor],Optional[Tensor]],Callable[[Tensor,Tensor,float],Tensor]]],AbsPassiveGenerator]) – Either a list of passive-volume functions (and optional targets together in a tuple), or a passive-volume generatorn_passives (
Optional[int]) – if a generator is used, this determines the number of volumes to generator per epoch in training, or in total when predictingshuffle (
bool) – If a list of pre-specified layouts is provided, their order will be shuffled if this is True
- class tomopt.optimisation.data.passives.RandomBlockPassiveGenerator(volume, block_size, sort_x0, enforce_diff_mat, block_size_max_half=None, materials=None)[source]¶
Bases:
AbsBlockPassiveGeneratorGenerates new passive layouts which contain a single cuboid of material (block) of random material against a random background material. Blocks are always present, but can potentially be of the same material as the background. The target for the volumes is the X0 of the block material.
The
generate()method will return only the layout function and no target Theget_data()method will return both the layout function and the targetThe block will be centred randomly in the volume, and can either be of fixed or random size.
- Parameters:
volume (
Volume) – Volume that the passive layout will be loaded intoblock_size (
Optional[Tuple[float,float,float]]) – if set, will generate blocks of the specified size and random orientation, otherwise will randomly set the size of the blockssort_x0 (
bool) – if True, the block will always have a lower X0 than the background, unless they are of the same materialenforce_diff_mat (
bool) – if True, the block will always be of a different material to the backgroundblock_size_max_half (
Optional[bool]) – if True and block_size is None, the maximum size of blocks will be set to half the size of the passive volumematerials (
Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt
- class tomopt.optimisation.data.passives.VoxelPassiveGenerator(volume, materials=None)[source]¶
Bases:
AbsPassiveGeneratorGenerates new passive layouts where every voxel is of a random material.
The
generate()method will return only the layout function and no target Theget_data()method will return both the layout function and the target- Parameters:
volume (
Volume) – Volume that the passive layout will be loaded intomaterials (
Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt