Transforms#
Submodules#
conex.helpers.transforms.encoders module#
- class conex.helpers.transforms.encoders.SimplePoisson(time_window, ratio)[source]#
Bases:
ModuleSimple Poisson encoding. Input values should be between 0 and 1. Spike rate is increased linearly with regard to the values. This transformer uses regular random generator provided for torch.rand.
- Parameters:
time_window (int) – The interval of the coding.
ratio (float) – A scale factor for probability of spiking.
- training: bool#
- class conex.helpers.transforms.encoders.Poisson(time_window, ratio)[source]#
Bases:
ModulePoisson encoding. Input values should be between 0 and 1. The intervals between two spikes are picked using Poisson Distribution.
- Parameters:
time_window (int) – The interval of the coding.
ratio (float) – A scale factor for probability of spiking.
- training: bool#
- class conex.helpers.transforms.encoders.Intensity2Latency(time_window, threshold=None, sparsity=None, min_val=0.0, max_val=1.0, lower_trim=True, higher_trim=True)[source]#
Bases:
ModuleIntensity to latency encoding. Stronger values spikes sooner.
- Parameters:
time_windows (int) – The interval of the coding.
threshold (float) – If not None, values lower than threshold will not spike.
sparsity (float) – If not None, defines a threshold for each input based on sparsity.
min_val (float) – Minimum possible value of input. The default is 0.0.
max_val (float) – Maximum possible value of input. The default is 1.0.
lower_trim (bool) – If True, spikes are transformed in order to have the last spike on the end of the interval. The default is True.
higher_trim (bool) – If True, spikes are transformed in order to have the first spike on the first of the interval. The default is True.
- training: bool#
conex.helpers.transforms.masks module#
- class conex.helpers.transforms.masks.GridEraseMask(m, n, random=False, gap=(0, 0, 0, 0))[source]#
Bases:
objectA Transformer that Grids input and removes only one cell. Adding a new dimension in position for total number of cells. Inputs should have channel at first index.
- Parameters:
m (int) – The grid row size.
n (int) – The grid column size.
random (bool) – If true, shuffles the order of the masks.
gap (tuple(int)) – left, right, up, bottom gaps for the cell.
- class conex.helpers.transforms.masks.GridKeepMask(m, n, random=False, gap=(0, 0, 0, 0))[source]#
Bases:
objectA Transformer that Grids input and removes alls but only one cell. Adding a new dimension in position for total number of cells. Inputs should have channel at first index.
- Parameters:
m (int) – The grid row size.
n (int) – The grid column size.
random (bool) – If true, shuffles the order of the masks.
gap (tuple(int)) – left, right, up, bottom gaps for the cell.
- class conex.helpers.transforms.masks.GridCropMask(m, n, random=False, gap=(0, 0, 0, 0))[source]#
Bases:
objectA Transformer that Grids input and crops to one cell. Adding a new dimension in position for total number of cells. Inputs should have channel at first index.
- Parameters:
m (int) – The grid row size.
n (int) – The grid column size.
random (bool) – If true, shuffles the order of the masks.
gap (tuple(int)) – left, right, up, bottom gaps for the cell.
conex.helpers.transforms.misc module#
- class conex.helpers.transforms.misc.UnsqueezeTransform(dim)[source]#
Bases:
ModuleApply pytorch unsqueeze function.
- Parameters:
dim (int) – The index to insert new dimension
- training: bool#
- class conex.helpers.transforms.misc.SqueezeTransform(dim)[source]#
Bases:
ModuleApply pytorch squeeze function.
- Parameters:
dim (int) – The index to remove a singleton dimension. Ff None all singleton dimensions will be removed.
- training: bool#
- class conex.helpers.transforms.misc.SwapTransform(axis1, axis2)[source]#
Bases:
ModuleTranspose two axes of input.
- Parameters:
axis1 (int) – The first dimension to be transposed.
axis2 (int) – The second dimension to be transposed.
- training: bool#
- class conex.helpers.transforms.misc.DeviceTransform(device)[source]#
Bases:
ModuleTransfer data to new device.
- Parameters:
device (str) – Device where data will located on.
- training: bool#
- class conex.helpers.transforms.misc.Conv2dFilter(filters, stride=1, padding=0)[source]#
Bases:
ModuleConvolve a filter on data.
- Parameters:
filter (str) – Filter to convolve data with.
stride (int or tuple) – Stride of the convolution. the default is 1.
padding (int or tuple) – Padding added to all four sides of the input. the default is 0.
- training: bool#
- class conex.helpers.transforms.misc.AbsoluteTransform(*args, **kwargs)[source]#
Bases:
ModuleApply pytorch absolute function on data.
- training: bool#
- class conex.helpers.transforms.misc.DivideSignPolarity(*args, **kwargs)[source]#
Bases:
ModuleDivide positive and negative values. The transformed data will have double size for the first dimension with first have all negative values changed to zero and second half with the absolute of the negative values.
- training: bool#