= SeqSlice(r_slc=-1)
l_shift = np.ones((5))
arr -1]) test_eq(l_shift(arr),arr[:
Corefunctions
Corefunctionality for data preparation of sequential data for pytorch, fastai models
3. Transformations
3.1 Sequence Slicing Transformation
SeqSlice
SeqSlice (l_slc=None, r_slc=None)
Take a slice from an array-like object. Useful for e.g. shifting input and output
3.2 Sequence Noise Injection Transformation
SeqNoiseInjection
SeqNoiseInjection (std=0.1, mean=0.0, p=1.0)
A transform that before_call its state at each __call__
= TensorSequencesInput(tensor([[1,1,1],[-1,-1,-1.0]]))
x = tensor([0.,10.1,3.1])
ns_mean = tensor([1.,1.1,0.1])
ns_std x,x.shape
(TensorSequencesInput([[ 1., 1., 1.],
[-1., -1., -1.]]),
torch.Size([2, 3]))
= SeqNoiseInjection(std=ns_std,mean=ns_mean)
seq_noise seq_noise(x)
TensorSequencesInput([[ 1., 1., 1.],
[-1., -1., -1.]])
= SeqNoiseInjection(std=ns_std*10)
seq_noise seq_noise(x)
TensorSequencesInput([[ 1., 1., 1.],
[-1., -1., -1.]])
SeqNoiseInjection_Varying
SeqNoiseInjection_Varying (std_std=0.1, p=1.0)
A transform that before_call its state at each __call__
= TensorSequencesInput(tensor([[0,0,0],[0,0,0]]))
x = tensor([1.,1.1,0.1])
ns_std x,x.shape
(TensorSequencesInput([[0, 0, 0],
[0, 0, 0]]),
torch.Size([2, 3]))
= SeqNoiseInjection_Varying(std_std=ns_std)
seq_noise seq_noise(x)
TensorSequencesInput([[0, 0, 0],
[0, 0, 0]])
SeqNoiseInjection_Grouped
SeqNoiseInjection_Grouped (std_std, std_idx, p=1.0)
A transform that before_call its state at each __call__
= TensorSequencesInput(tensor([[0,0,0],[0,0,0]]))
x = tensor([1.,1.1,0.1])
ns_std x,x.shape
(TensorSequencesInput([[0, 0, 0],
[0, 0, 0]]),
torch.Size([2, 3]))
= SeqNoiseInjection_Grouped(std_std=[3.,0],std_idx=[0,0,1])
seq_noise seq_noise(x)
TensorSequencesInput([[0, 0, 0],
[0, 0, 0]])
3.2 Sequence Bias Injection Transformation
SeqBiasInjection
SeqBiasInjection (std=0.1, mean=0.0, p=1.0)
A transform that before_call its state at each __call__
= TensorSequencesInput(tensor([[[1,1,1],[-1,-1,-1.0]]]))
x = tensor([0.,10.1,3.1])
ns_mean = tensor([1.,1.1,0.1])
ns_std = SeqBiasInjection(std=ns_std,mean=ns_std)
seq_bias 0] seq_bias(x)[...,
TensorSequencesInput([[ 1., -1.]])
seq_bias.mean
tensor([1.0000, 1.1000, 0.1000])
= SeqBiasInjection(std=ns_std*10)
seq_bias seq_bias(x)
TensorSequencesInput([[[ 1., 1., 1.],
[-1., -1., -1.]]])
3.3 Normalization
Normalize
is programmed for TensorImage
as an input tensor. It gets. At init the variable axes need to be chosen correspondingly to the shape of your tensor.
decodes
decodes (x:tsfast.data.core.TensorSequencesInput)
encodes
encodes (x:tsfast.data.core.TensorSequencesInput)
= Normalize.from_stats(mean=ns_mean,std=ns_std,dim=1,ndim=2,cuda=False)
norm x,norm(x)
(TensorSequencesInput([[[ 1., 1., 1.],
[-1., -1., -1.]]]),
TensorSequencesInput([[[ 1.0000, -8.2727, -21.0000],
[ -1.0000, -10.0909, -41.0000]]]))