示例#1
0
文件: test_sofm.py 项目: Xnsam/neupy
    def test_invalid_attrs(self):
        with self.assertRaisesRegexp(ValueError, "Feature grid"):
            # Invalid feature grid shape
            algorithms.SOFM(n_inputs=2, n_outputs=4, features_grid=(2, 3))

        with self.assertRaisesRegexp(ValueError, "n_outputs, features_grid"):
            algorithms.SOFM(n_inputs=2)

        with self.assertRaisesRegexp(ValueError, "more than 2 dimensions"):
            sofm = algorithms.SOFM(n_inputs=2, n_outputs=3, weight=self.weight)
            sofm.train(np.zeros((10, 2, 1)))

        with self.assertRaisesRegexp(ValueError, "more than 2 dimensions"):
            sofm = algorithms.SOFM(n_inputs=2, n_outputs=3, weight=self.weight)
            sofm.predict(np.zeros((10, 2, 1)))

        with self.assertRaisesRegexp(ValueError, "Input data expected"):
            sofm = algorithms.SOFM(n_inputs=2, n_outputs=3, weight=self.weight)
            sofm.train(np.zeros((10, 10)))

        with self.assertRaisesRegexp(ValueError, "Input data expected"):
            sofm = algorithms.SOFM(n_inputs=2, n_outputs=3, weight=self.weight)
            sofm.predict(np.zeros((10, 10)))

        with self.assertRaisesRegexp(ValueError, "one or two dimensional"):
            algorithms.SOFM(n_inputs=2,
                            features_grid=(3, 1, 1),
                            grid_type='hexagon')
示例#2
0
文件: test_sofm.py 项目: Xnsam/neupy
 def test_sofm_1d_vector_input(self):
     sofm = algorithms.SOFM(
         n_inputs=2,
         n_outputs=3,
         weight=self.weight,
     )
     output = sofm.predict(input_data[0])
     self.assertEqual(output.shape, (1, 3))