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: 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: 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