3703673d516335d7c5188b954e6bf7d123c646ba,tensorflow_transform/mappers_test.py,MappersTest,testNGrams,#MappersTest#,40

Before Change


  def testNGrams(self):
    output_tensor = mappers.ngrams(
        tf.constant(["abc", "def", "fghijklm", "z", ""]), (1, 5))
    with tf.Session():
      output = output_tensor.eval()
      self.assertAllEqual(
          output.indices,
          [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5],
           [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5],
           [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7],
           [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15],
           [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22],
           [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29],
           [3, 0]])
      self.assertAllEqual(output.values, [
          "a", "ab", "abc", "b", "bc", "c",
          "d", "de", "def", "e", "ef", "f",
          "f", "fg", "fgh", "fghi", "fghij", "g", "gh", "ghi", "ghij", "ghijk",
          "h", "hi", "hij", "hijk", "hijkl", "i", "ij", "ijk", "ijkl", "ijklm",
          "j", "jk", "jkl", "jklm", "k", "kl", "klm", "l", "lm", "m",
          "z"])
      self.assertAllEqual(output.dense_shape, [5, 30])

  def testNGramsMinSizeNotOne(self):
    output_tensor = mappers.ngrams(
        tf.constant(["abc", "def", "fghijklm", "z", ""]), (2, 5))
    with tf.Session():

After Change


        tokens=tokenized_tensor,
        ngram_range=(1, 5),
        separator="")
    self.assertSparseOutput(
        expected_indices=[
            [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5],
            [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5],
            [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7],
            [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14],
            [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21],
            [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28],
            [2, 29], [3, 0]],
        expected_values=[
            "a", "ab", "abc", "b", "bc", "c",
            "d", "de", "def", "e", "ef", "f",
            "f", "fg", "fgh", "fghi", "fghij", "g", "gh", "ghi", "ghij",
            "ghijk", "h", "hi", "hij", "hijk", "hijkl", "i", "ij", "ijk",
            "ijkl", "ijklm", "j", "jk", "jkl", "jklm", "k", "kl", "klm", "l",
            "lm", "m", "z"],
        expected_shape=[5, 30],
        actual_sparse_tensor=output_tensor,
        close_values=False)

  def testNGramsMinSizeNotOne(self):
    string_tensor = tf.constant(["abc", "def", "fghijklm", "z", ""])
    tokenized_tensor = tf.string_split(string_tensor, delimiter="")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 5

Instances


Project Name: tensorflow/transform
Commit Name: 3703673d516335d7c5188b954e6bf7d123c646ba
Time: 2017-06-02
Author: no-reply@google.com
File Name: tensorflow_transform/mappers_test.py
Class Name: MappersTest
Method Name: testNGrams


Project Name: tensorflow/transform
Commit Name: 3703673d516335d7c5188b954e6bf7d123c646ba
Time: 2017-06-02
Author: no-reply@google.com
File Name: tensorflow_transform/mappers_test.py
Class Name: MappersTest
Method Name: testNGramsMinSizeNotOne


Project Name: tensorflow/cleverhans
Commit Name: ff37eb82ddba183c5881716d15bbc9ebfa9aeee9
Time: 2018-10-08
Author: windqaq@gmail.com
File Name: tests_tf/test_utils_tf.py
Class Name: TestUtilsTF
Method Name: test_l2_batch_normalize


Project Name: tensorlayer/tensorlayer
Commit Name: 910e1e544793c0ca9859a5a4f1c0171104166dc3
Time: 2019-03-10
Author: jingqing.zhang15@imperial.ac.uk
File Name: tests/layers/test_layers_core_basedense_dropout.py
Class Name: Layer_Core_Test
Method Name: test_modellayer