Esempio n. 1
0
  def test_get_hidden_node_location_text(self):
    num_channels = 128
    output_activation_map_shape = (498, 1)
    flattened_indices = np.arange(
        num_channels * output_activation_map_shape[0]).reshape(
            num_channels, output_activation_map_shape[0],
            output_activation_map_shape[1])
    true_row = np.random.randint(low=0, high=output_activation_map_shape[0])
    true_channel = np.random.randint(low=0, high=num_channels)
    true_column = 0

    (predicted_channel, predicted_row,
     predicted_column) = masking._get_hidden_node_location(
         flattened_index=flattened_indices[true_channel][true_row][true_column],
         num_rows=output_activation_map_shape[0],
         num_columns=output_activation_map_shape[1])

    self.assertEqual(true_channel, predicted_channel)
    self.assertEqual(true_row, predicted_row)
    self.assertEqual(true_column, predicted_column)
Esempio n. 2
0
  def test_get_hidden_node_location_image(self):
    num_channels = 64
    output_activation_map_size = 112
    flattened_indices = np.arange(
        num_channels * output_activation_map_size ** 2).reshape(
            num_channels, output_activation_map_size,
            output_activation_map_size)
    true_row = np.random.randint(low=0, high=output_activation_map_size)
    true_column = np.random.randint(low=0, high=output_activation_map_size)
    true_channel = np.random.randint(low=0, high=num_channels)

    (predicted_channel, predicted_row,
     predicted_column) = masking._get_hidden_node_location(
         flattened_index=flattened_indices[true_channel][true_row][true_column],
         num_rows=output_activation_map_size,
         num_columns=output_activation_map_size)

    self.assertEqual(true_channel, predicted_channel)
    self.assertEqual(true_row, predicted_row)
    self.assertEqual(true_column, predicted_column)