Пример #1
0
 def _classify(self, strings):
     strings = [language_detection_textcleaning(i) for i in strings]
     subs = [
         ' '.join(s)
         for s in self._bpe.encode(strings, output_type = self._type)
     ]
     transformed = self._vectorizer.transform(subs)
     batch_x = _convert_sparse_matrix_to_sparse_tensor(transformed)
     probs = self._sess.run(
         self._softmax,
         feed_dict = {self._model.X: batch_x[0], self._model.W: batch_x[1]},
     )
     return probs
Пример #2
0
 def _classify(self, strings):
     strings = [language_detection_textcleaning(i) for i in strings]
     subs = [
         ' '.join(s)
         for s in self._bpe.bpe.encode(strings, output_type=self._bpe.mode)
     ]
     transformed = self._vectorizer.transform(subs)
     batch_x = _convert_sparse_matrix_to_sparse_tensor(transformed)
     r = self._execute(
         inputs=batch_x,
         input_labels=[
             'X_Placeholder/shape',
             'X_Placeholder/values',
             'X_Placeholder/indices',
             'W_Placeholder/shape',
             'W_Placeholder/values',
             'W_Placeholder/indices',
         ],
         output_labels=['logits'],
     )
     probs = softmax(r['logits'], axis=-1)
     return probs
Пример #3
0
 def _predict(self, strings):
     strings = [
         language_detection_textcleaning(string) for string in strings
     ]
     return self._model.predict(strings)