Exemplo n.º 1
0
 def _predict(self, X):
     if not self._initialized:
         raise NotFittedError()
     predict_data_feeder = setup_predict_data_feeder(X)
     preds = []
     for data in predict_data_feeder:
         preds.append(
             self._session.run(self._model_predictions,
                               feed_dict={self._inp.name: data}))
     return np.concatenate(preds, axis=0)
Exemplo n.º 2
0
 def _predict(self, X):
     if not self._initialized:
         raise NotFittedError()
     predict_data_feeder = setup_predict_data_feeder(X)
     preds = []
     for data in predict_data_feeder:
         preds.append(self._session.run(
             self._model_predictions,
             feed_dict={
                 self._inp.name: data
             }))
     return np.concatenate(preds, axis=0)
Exemplo n.º 3
0
 def _predict(self, X):
     if not self._initialized:
         raise NotFittedError()
     self._graph.add_to_collection("IS_TRAINING", False)
     predict_data_feeder = setup_predict_data_feeder(X)
     preds = []
     dropouts = self._graph.get_collection(DROPOUTS)
     feed_dict = {prob: 1.0 for prob in dropouts}
     for data in predict_data_feeder:
         feed_dict[self._inp] = data
         preds.append(self._session.run(self._model_predictions, feed_dict))
     return np.concatenate(preds, axis=0)
Exemplo n.º 4
0
 def _predict(self, X):
     if not self._initialized:
         raise NotFittedError()
     predict_data_feeder = setup_predict_data_feeder(X)
     preds = []
     dropouts = self._graph.get_collection(DROPOUTS)
     feed_dict = {prob: 1.0 for prob in dropouts}
     for data in predict_data_feeder:
         feed_dict[self._inp] = data
         preds.append(self._session.run(
             self._model_predictions,
             feed_dict))
     return np.concatenate(preds, axis=0)
Exemplo n.º 5
0
    def _predict(self, X, axis=-1, batch_size=-1):
        if not self._initialized:
            raise NotFittedError()
        self._graph.add_to_collection("IS_TRAINING", False)
        predict_data_feeder = setup_predict_data_feeder(X,
                                                        batch_size=batch_size)
        preds = []
        dropouts = self._graph.get_collection(DROPOUTS)
        feed_dict = {prob: 1.0 for prob in dropouts}
        for data in predict_data_feeder:
            feed_dict[self._inp] = data
            predictions_for_batch = self._session.run(self._model_predictions,
                                                      feed_dict)
            if self.n_classes > 1 and axis != -1:
                preds.append(predictions_for_batch.argmax(axis=axis))
            else:
                preds.append(predictions_for_batch)

        return np.concatenate(preds, axis=0)
Exemplo n.º 6
0
    def _predict(self, X, axis=-1, batch_size=-1):
        if not self._initialized:
            raise NotFittedError()
        self._graph.add_to_collection("IS_TRAINING", False)
        predict_data_feeder = setup_predict_data_feeder(
            X, batch_size=batch_size)
        preds = []
        dropouts = self._graph.get_collection(DROPOUTS)
        feed_dict = {prob: 1.0 for prob in dropouts}
        for data in predict_data_feeder:
            feed_dict[self._inp] = data
            predictions_for_batch = self._session.run(
                self._model_predictions,
                feed_dict)
            if self.n_classes > 1 and axis != -1:
                preds.append(predictions_for_batch.argmax(axis=axis))
            else:
                preds.append(predictions_for_batch)

        return np.concatenate(preds, axis=0)
Exemplo n.º 7
0
 def test_iterable_data(self):
     X = iter([[1, 2], [3, 4], [5, 6]])
     df = setup_predict_data_feeder(X, batch_size=2)
     self.assertAllClose(six.next(df), [[1, 2], [3, 4]])
     self.assertAllClose(six.next(df), [[5, 6]])
Exemplo n.º 8
0
 def test_iterable_data(self):
     X = iter([[1, 2], [3, 4], [5, 6]])
     df = setup_predict_data_feeder(X, batch_size=2)
     self.assertAllClose(six.next(df), [[1, 2], [3, 4]])
     self.assertAllClose(six.next(df), [[5, 6]])