예제 #1
0
  def inference_graph(self, data):
    with ops.device(self.device_assigner):
      routes = gen_training_ops.routing_function(
          data,
          self.tree_parameters,
          self.tree_thresholds,
          max_nodes=self.params.num_nodes)

      leaf_routes = array_ops.slice(
          routes, [0, self.params.num_nodes - self.params.num_leaves - 1],
          [-1, self.params.num_leaves])

      return leaf_routes
예제 #2
0
    def inference_graph(self, data):
        with ops.device(self.device_assigner):
            routing_probabilities = gen_training_ops.routing_function(
                data,
                self.tree_parameters,
                self.tree_thresholds,
                max_nodes=self.params.num_nodes)

            output = array_ops.slice(
                routing_probabilities,
                [0, self.params.num_nodes - self.params.num_leaves - 1],
                [-1, self.params.num_leaves])

            return output
예제 #3
0
  def testRoutingFunction(self):
    with self.cached_session():
      route_tensor = gen_training_ops.routing_function(
          self.input_data, self.tree_weights, self.tree_thresholds, max_nodes=3)

      route_tensor_shape = route_tensor.get_shape()
      self.assertEquals(len(route_tensor_shape), 2)
      self.assertEquals(route_tensor_shape[0], 4)
      self.assertEquals(route_tensor_shape[1], 3)

      routes = route_tensor.eval()

      # Point 1
      # Node 1 is a decision node => probability = 1.0
      self.assertAlmostEquals(1.0, routes[0, 0])
      # Probability left output = 1.0 / (1.0 + exp(1.0)) = 0.26894142
      self.assertAlmostEquals(0.26894142, routes[0, 1])
      # Probability right = 1 - 0.2689414 = 0.73105858
      self.assertAlmostEquals(0.73105858, routes[0, 2])