Exemplo n.º 1
0
 def test_data_feeder_multioutput_regression(self):
     X = np.matrix([[1, 2], [3, 4]])
     y = np.array([[1, 2], [3, 4]])
     df = data_feeder.DataFeeder(X, y, n_classes=0, batch_size=2)
     feed_dict_fn = df.get_feed_dict_fn(MockPlaceholder(name='input'),
                                        MockPlaceholder(name='output'))
     feed_dict = feed_dict_fn()
     self.assertAllClose(feed_dict['input'], [[3, 4], [1, 2]])
     self.assertAllClose(feed_dict['output'], [[3, 4], [1, 2]])
Exemplo n.º 2
0
 def _setup_data_feeder(self, X, y):
     """Create data feeder, to sample inputs from dataset.
     If X and y are iterators, use StreamingDataFeeder.
     """
     if hasattr(X, 'next'):
         assert hasattr(y, 'next')
         self._data_feeder = data_feeder.StreamingDataFeeder(
             X, y, self.n_classes, self.batch_size)
     else:
         self._data_feeder = data_feeder.DataFeeder(X, y, self.n_classes,
                                                    self.batch_size)
Exemplo n.º 3
0
 def test_data_feeder_multioutput_classification(self):
     random.seed(42)
     X = np.matrix([[1, 2], [3, 4]])
     y = np.array([[0, 1, 2], [2, 3, 4]])
     df = data_feeder.DataFeeder(X, y, n_classes=5, batch_size=2)
     feed_dict_fn = df.get_feed_dict_fn(MockPlaceholder(name='input'),
                                        MockPlaceholder(name='output'))
     feed_dict = feed_dict_fn()
     self.assertAllClose(feed_dict['input'], [[3, 4], [1, 2]])
     self.assertAllClose(
         feed_dict['output'],
         [[[0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],
          [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0]]])