Shortcuts

asteroid.utils.generic_utils module

asteroid.utils.generic_utils.average_arrays_in_dic(dic)[source]

Take average of numpy arrays in a dictionary.

Parameters:dic (dict) – Input dictionary to take average from
Returns:dict – New dictionary with array averaged.
asteroid.utils.generic_utils.flatten_dict(d, parent_key='', sep='_')[source]

Flattens a dictionary into a single-level dictionary while preserving parent keys. Taken from https://stackoverflow.com/questions/6027558/ flatten-nested-dictionaries-compressing-keys?answertab=votes#tab-top

Parameters:
  • d (MutableMapping) – Dictionary to be flattened.
  • parent_key (str) – String to use as a prefix to all subsequent keys.
  • sep (str) – String to use as a separator between two key levels.
Returns:

dict – Single-level dictionary, flattened.

asteroid.utils.generic_utils.get_wav_random_start_stop(signal_len, desired_len=32000)[source]

Get indexes for a chunk of signal of a given length.

Parameters:
  • signal_len (int) – length of the signal to trim.
  • desired_len (int) – the length of [start:stop]
Returns:

tuple – random start integer, stop integer.

asteroid.utils.generic_utils.has_arg(fn, name)[source]

Checks if a callable accepts a given keyword argument.

Parameters:
  • fn (callable) – Callable to inspect.
  • name (str) – Check if fn can be called with name as a keyword argument.
Returns:

bool – whether fn accepts a name keyword argument.

asteroid.utils.generic_utils.unet_decoder_args(encoders, *, skip_connections)[source]

Get list of decoder arguments for upsampling (right) side of a symmetric u-net, given the arguments used to construct the encoder.

Parameters:
  • encoders (list of length N of tuples of (in_chan, out_chan, kernel_size, stride, padding)) – List of arguments used to construct the encoders
  • skip_connections (bool) – Whether to include skip connections in the calculation of decoder input channels.
Returns:

list of length N of tuples of (in_chan, out_chan, kernel_size, stride, padding) – Arguments to be used to construct decoders

Read the Docs v: v0.3.5
Versions
latest
stable
v0.3.5_b
v0.3.4
v0.3.3
v0.3.2
v0.3.1
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.