def test_Layer_invertibility(): layer = mh.Layer(_pca_nodes([10, 17, 3], [10, 17, 3])) x = numx_rand.random([100, 30]).astype('f') layer.train(x) y = layer.execute(x) x_inverse = layer.inverse(y) assert numx.all(numx.absolute(x - x_inverse) < 0.001)
def test_Layer_invertibility2(): # reduce the dimensions, so input_dim != output_dim layer = mh.Layer(_pca_nodes([10, 17, 3], [8, 12, 3])) x = numx_rand.random([100, 30]).astype('f') layer.train(x) y = layer.execute(x) layer.inverse(y)
def test_Layer(): layer = mh.Layer(_pca_nodes([10, 17, 3], [5, 3, 1])) x = numx_rand.random([100, 30]).astype('f') layer.train(x) y = layer.execute(x) assert layer.dtype == numx.dtype('f') assert y.dtype == layer.dtype