mxfusion.util.util

Members

mxfusion.util.util.slice_axis(F, array, axis, indices)

Slice an array along a given axis by a list of indices.

Parameters:
  • array (MXNet Array) – the array to be sliced.
  • axis (int) – the axis to be sliced.
  • indices (list or MXNet Array) – the indices used in slicing
mxfusion.util.util.rename_duplicate_names(names)

Given a list of names, rename the duplicated names by appending an integer at the end. This function returns a list of tuples each of which contains an index of the duplicate name and a new name. For example, [‘a’, ‘b’, ‘a’, ‘a’] -> [(2, ‘a0’), (3, ‘a0’)] [‘a’, ‘b’] -> []

Parameters:names ([str]) – the list of names
Returns:a list of tuples each of which contains an index of the duplicate name and a new name.
Rtypes:[tuple]
mxfusion.util.util.parse_string_to_tuple(s)
mxfusion.util.util.add_mxnet_params(block, var, grad_req='write')

This function adds MXFusion variables to the MXNet Gluon block’s parameters for use in computations via the params variable or kwargs parameter in hybrid_forward()

Parameters:
  • block – MXNet Gluon Block to add the parameters into
  • var – array of MXFusion variables to add to the block
  • grad_req – gradient required for these variables?
Returns:

mxfusion.util.util.create_variables_with_names(names)

Utility function to create a dictionary of Variables from a list of names.

Param:names list of names
mxfusion.util.util.create_constant_from_values(var)

Utility function to createa a constant variable from a raw value.

Param:var the value of the constant