mxfusion.util.testutils¶
Members¶
-
mxfusion.util.testutils.
prepare_mxnet_array
(array, array_has_samples, dtype)¶
-
mxfusion.util.testutils.
numpy_array_reshape
(var, isSamples, n_dim)¶ Reshape a numpy to a give dimensionality by adding dimensions with size one in front (broadcasting). If isSamples is true, keep the first dimension.
Parameters: - var (numpy.ndarray) – the variable to be reshaped.
- isSamples (boolean) – whether the variable is a sampled variable with the first dimension being the number of samples.
- n_dim (int) – the dimensionality that the variable is reshaped to.
Returns: the reshaped numpy array
Return type: numpy.ndarray
-
class
mxfusion.util.testutils.
MockMXNetRandomGenerator
(samples)¶ Bases:
mxfusion.components.distributions.random_gen.RandomGenerator
The MXNet pseudo-random number generator.
-
sample_normal
(loc=0, scale=1, shape=None, dtype=None, out=None, ctx=None, F=None)¶
-
sample_multinomial
(data, shape=None, get_prob=True, dtype=None, F=None)¶
-
sample_bernoulli
(prob_true=0.5, shape=None, dtype=None, out=None, F=None)¶
-
sample_gamma
(alpha=1, beta=1, shape=None, dtype=None, out=None, ctx=None, F=None)¶
-
sample_uniform
(low=0.0, high=1.0, shape=None, dtype=None, out=None, ctx=None, F=None)¶
-
sample_laplace
(location=0.0, scale=1.0, shape=None, dtype=None, out=None, ctx=None, F=None)¶
-
-
mxfusion.util.testutils.
make_net
()¶
-
mxfusion.util.testutils.
make_basic_model
(finalize=True, verbose=True)¶
-
mxfusion.util.testutils.
make_bnn_model
(finalize=True, verbose=True)¶
-
class
mxfusion.util.testutils.
DotProduct
(prefix=None, params=None)¶ Bases:
mxnet.gluon.block.HybridBlock
-
hybrid_forward
(F, x, *args, **kwargs)¶ Overrides to construct symbolic graph for this Block.
Parameters: - x (Symbol or NDArray) – The first input tensor.
- *args (list of Symbol or list of NDArray) – Additional input tensors.
-
-
class
mxfusion.util.testutils.
TestBlock
¶ Bases:
mxnet.gluon.block.HybridBlock
Block with standard functions for initializing and running an MXNet Gluon block for unit testing.
-
hybrid_forward
(F, x, var1, var2)¶ Simple test function to enable MXFusion tests that use a Gluon block. :param F: MXNet computation type <mx.sym, mx.nd> :param x: MXNet dummy variable :param var1: MXNet dummy variable :param var2: MXNet dummy variable
-
-
mxfusion.util.testutils.
plot_univariate
(samples, dist, buffer=0, **kwargs)¶ Visual inspection by plotting the distribution: plots a histogram of the samples along with
Parameters: - samples ((mx.nd.NDArray, np.ndarray)) – Samples from the distribution
- buffer – additional range to plot the distribution over
- dist – Distribution that these are samples from (scipy.stats)
- kwargs – Keyword arguments for the distribution (e.g. loc, scale)
-
mxfusion.util.testutils.
plot_bivariate
(samples, dist, buffer=0, **kwargs)¶ Visual inspection by plotting the distribution: plots a scatter plot of samples along with a contour plot
Parameters: - samples ((mx.nd.NDArray, np.ndarray)) – Samples from the distribution
- buffer – additional range to plot the distribution over
- dist – Distribution that these are samples from (scipy.stats)
- kwargs – Keyword arguments for the distribution (e.g. loc, scale)