def test_mlp_fit(): X = np.random.standard_normal((10, 2)) Z = np.random.standard_normal((10, 1)) X, Z = theano_floatx(X, Z) mlp = Mlp(2, [10], 1, ['tanh'], 'identity', 'squared', max_iter=10) mlp.fit(X, Z)
def test_mlp_fit_with_imp_weight(): X = np.random.standard_normal((10, 2)) Z = np.random.standard_normal((10, 1)) W = np.random.random((10, 1)) > 0.5 X, Z, W = theano_floatx(X, Z, W) mlp = Mlp(2, [10], 1, ['tanh'], 'identity', 'squared', max_iter=10, imp_weight=True) mlp.fit(X, Z, W)
def test_mlp_pickle(): X = np.random.standard_normal((10, 2)) Z = np.random.standard_normal((10, 1)) X, Z = theano_floatx(X, Z) mlp = Mlp(2, [10], 1, ['tanh'], 'identity', 'squared', max_iter=2) climin.initialize.randomize_normal(mlp.parameters.data, 0, 1) mlp.fit(X, Z) Y = mlp.predict(X) pickled = cPickle.dumps(mlp) mlp2 = cPickle.loads(pickled) Y2 = mlp2.predict(X) assert np.allclose(Y, Y2)