Nabu-asr
Functions
ops.py File Reference

some operations More...

Functions

def nabu.neuralnetworks.components.ops.pyramid_stack (inputs, sequence_lengths, numsteps, axis=2, scope=None)
 concatenate each two consecutive elements More...
 
def nabu.neuralnetworks.components.ops.stack_seq (sequential, sequence_lengths, name=None)
 remove padding and stack sequences More...
 
def nabu.neuralnetworks.components.ops.unstack_seq (nonseq, sequence_lengths, name=None)
 unstack sequences and add padding More...
 
def nabu.neuralnetworks.components.ops.dense_sequence_to_sparse (sequences, sequence_lengths)
 convert sequence dense representations to sparse representations More...
 
def nabu.neuralnetworks.components.ops.get_indices (sequence_length)
 get the indices corresponding to sequences (and not padding) More...
 
def nabu.neuralnetworks.components.ops.pad_to (tensor, length, axis=0, name=None)
 pad the tensor to a certain length More...
 
def nabu.neuralnetworks.components.ops.map_ta (fn, ta)
 apply fn to each element in tensorarray More...
 

Detailed Description

some operations

Function Documentation

§ dense_sequence_to_sparse()

def nabu.neuralnetworks.components.ops.dense_sequence_to_sparse (   sequences,
  sequence_lengths 
)

convert sequence dense representations to sparse representations

Parameters
sequencesthe dense sequences as a [batch_size x max_length] tensor
sequence_lengthsthe sequence lengths as a [batch_size] vector
Returns
the sparse tensor representation of the sequences

§ get_indices()

def nabu.neuralnetworks.components.ops.get_indices (   sequence_length)

get the indices corresponding to sequences (and not padding)

Parameters
sequence_lengththe sequence_lengths as a N-D tensor
Returns
A [sum(sequence_length) x N-1] Tensor containing the indices

§ map_ta()

def nabu.neuralnetworks.components.ops.map_ta (   fn,
  ta 
)

apply fn to each element in tensorarray

Parameters
fnthe function to apply
tathe tensorarray
Returns
the resulting tensorarray

§ pad_to()

def nabu.neuralnetworks.components.ops.pad_to (   tensor,
  length,
  axis = 0,
  name = None 
)

pad the tensor to a certain length

  • tensor: the tensor to pad
  • length: the length to pad to, has to be larger than tensor.shape[axis]
  • axis: the axis to pad
  • name: the name of the operation
Returns
the padded tensor

§ pyramid_stack()

def nabu.neuralnetworks.components.ops.pyramid_stack (   inputs,
  sequence_lengths,
  numsteps,
  axis = 2,
  scope = None 
)

concatenate each two consecutive elements

Parameters
inputsA time minor tensor [batch_size, time, input_size]
sequence_lengthsthe length of the input sequences
numstepsnumber of time steps to concatenate
axisthe axis where the inputs should be stacked
scopethe current scope
Returns
inputs Concatenated inputs
[batch_size, time/numsteps, input_size*numsteps]
@return sequence_lengths the lengths of the inputs sequences [batch_size]

§ stack_seq()

def nabu.neuralnetworks.components.ops.stack_seq (   sequential,
  sequence_lengths,
  name = None 
)

remove padding and stack sequences

Parameters
sequentialthe sequential data which is a [batch_size, max_length, dim]
tensor
sequence_lengthsa [batch_size] vector containing the sequence lengths
name[optional] the name of the operation
Returns
non sequential data, which is a TxF tensor where T is the sum of all sequence lengths

§ unstack_seq()

def nabu.neuralnetworks.components.ops.unstack_seq (   nonseq,
  sequence_lengths,
  name = None 
)

unstack sequences and add padding

Parameters
nonseqthe non sequential data which is a [sum(sequence_lengths) x dim] tensor
sequence_lengthsa [batch_size] vector containing the sequence lengths
name[optional] the name of the operation
Returns
sequential data, which is a [batch_size, max_length, dim] tensor