Exemplo n.º 1
0
    def test_patchmcgsm_stationary(self):
        xmask = ones([2, 2], dtype='bool')
        ymask = zeros([2, 2], dtype='bool')
        xmask[-1, -1] = False
        ymask[-1, -1] = True

        model = PatchMCGSM(3,
                           3,
                           xmask,
                           ymask,
                           model=MCGSM(sum(xmask), 1, 2, 2))

        data = randn(4, 10000)

        model.initialize(data)
        model.train(data,
                    parameters={
                        'verbosity': 0,
                        'max_iter': 10,
                        'stationary': True,
                        'treshold': 1e-4
                    })

        self.assertTrue(all(model[0, 2].predictors == model[0, 1].predictors))
        self.assertFalse(all(model[1, 0].predictors == model[0, 1].predictors))
        self.assertTrue(all(model[1, 2].weights == model[1, 1].weights))
        self.assertTrue(all(model[1, 2].features == model[1, 1].features))
        self.assertTrue(all(model[1, 2].scales == model[1, 1].scales))
        self.assertTrue(all(model[1, 2].priors == model[1, 1].priors))

        xmask, ymask = generate_masks(3)

        model = PatchMCGSM(3,
                           3,
                           xmask,
                           ymask,
                           model=MCGSM(sum(xmask), 1, 2, 2))

        data = randn(4, 10000)

        model.initialize(data)
        model.train(data,
                    parameters={
                        'verbosity': 0,
                        'max_iter': 10,
                        'stationary': True,
                        'treshold': 1e-4
                    })

        self.assertTrue(all(model[0, 2].weights == model[0, 1].weights))
        self.assertTrue(all(model[2, 0].features == model[1, 0].features))
        self.assertTrue(all(model[2, 2].scales == model[1, 2].scales))
Exemplo n.º 2
0
    def test_patchmcgsm_train(self):
        xmask = ones([2, 2], dtype="bool")
        ymask = zeros([2, 2], dtype="bool")
        xmask[-1, -1] = False
        ymask[-1, -1] = True

        model = PatchMCGSM(2, 2, xmask, ymask, model=MCGSM(sum(xmask), 1, 1, 1))

        data = randn(4, 10000)

        model.initialize(data)
        converged = model.train(data, parameters={"verbosity": 0, "max_iter": 200, "treshold": 1e-4})

        self.assertTrue(converged)
Exemplo n.º 3
0
	def test_patchmcgsm_stationary(self):
		xmask = ones([2, 2], dtype='bool')
		ymask = zeros([2, 2], dtype='bool')
		xmask[-1, -1] = False
		ymask[-1, -1] = True

		model = PatchMCGSM(3, 3, xmask, ymask, model=MCGSM(sum(xmask), 1, 2, 2))

		data = randn(4, 10000)

		model.initialize(data)
		model.train(data, parameters={
			'verbosity': 0,
			'max_iter': 10,
			'stationary': True,
			'treshold': 1e-4})

		self.assertTrue(all(model[0, 2].predictors == model[0, 1].predictors))
		self.assertFalse(all(model[1, 0].predictors == model[0, 1].predictors))
		self.assertTrue(all(model[1, 2].weights == model[1, 1].weights))
		self.assertTrue(all(model[1, 2].features == model[1, 1].features))
		self.assertTrue(all(model[1, 2].scales == model[1, 1].scales))
		self.assertTrue(all(model[1, 2].priors == model[1, 1].priors))

		xmask, ymask = generate_masks(3)

		model = PatchMCGSM(3, 3, xmask, ymask, model=MCGSM(sum(xmask), 1, 2, 2))

		data = randn(4, 10000)

		model.initialize(data)
		model.train(data, parameters={
			'verbosity': 0,
			'max_iter': 10,
			'stationary': True,
			'treshold': 1e-4})

		self.assertTrue(all(model[0, 2].weights == model[0, 1].weights))
		self.assertTrue(all(model[2, 0].features == model[1, 0].features))
		self.assertTrue(all(model[2, 2].scales == model[1, 2].scales))
Exemplo n.º 4
0
    def test_patchmcgsm_train(self):
        xmask = ones([2, 2], dtype='bool')
        ymask = zeros([2, 2], dtype='bool')
        xmask[-1, -1] = False
        ymask[-1, -1] = True

        model = PatchMCGSM(2,
                           2,
                           xmask,
                           ymask,
                           model=MCGSM(sum(xmask), 1, 1, 1))

        data = randn(4, 10000)

        model.initialize(data)
        converged = model.train(data,
                                parameters={
                                    'verbosity': 0,
                                    'max_iter': 200,
                                    'treshold': 1e-4
                                })

        self.assertTrue(converged)