Пример #1
0
 def test_as_training_data_produces_correct_numpy_arrays(self):
     instance = IndexedTupleInstance([[1, 2], [3, 4], [5, 6]], True)
     inputs, _ = instance.as_training_data()
     assert numpy.all(inputs == numpy.asarray([[1, 2], [3, 4], [5, 6]]))
Пример #2
0
 def test_pad_adjusts_slots_before_length(self):
     instance = IndexedTupleInstance([[1, 2], [3, 4], [5, 6], [7, 8]], True)
     instance.pad({'word_sequence_length': 2, 'num_slots': 3})
     print(instance.word_indices)
     assert instance.word_indices == [[1, 2], [3, 4], [7, 8]]
Пример #3
0
 def test_pad_adds_zeros_on_all_slots(self):
     instance = IndexedTupleInstance([[1, 2], [3, 4, 5], [6]], True)
     instance.pad({'word_sequence_length': 4, 'num_slots': 3})
     assert instance.word_indices == [[0, 0, 1, 2], [0, 3, 4, 5], [0, 0, 0, 6]]
Пример #4
0
 def test_pad_slots_concatenates_at_end(self):
     instance = IndexedTupleInstance([[1, 2], [3, 4], [5, 6], [7, 8]], True)
     instance.pad({'word_sequence_length': 4, 'num_slots': 3})
     assert instance.word_indices == [[0, 0, 1, 2], [0, 0, 3, 4], [5, 6, 7, 8]]
Пример #5
0
 def test_get_lengths_returns_length_of_longest_slot(self):
     instance = IndexedTupleInstance([[1, 2], [3, 4, 5], [6]], True)
     assert instance.get_lengths() == {'word_sequence_length': 3, 'num_slots': 3}