tensorflow_probability/python/mcmc/nuts.py
def build_tree_uturn_instruction(max_depth, init_memory=0):
  """Run build tree and output the u turn checking input instruction."""

  def _buildtree(address, depth):
    if depth == 0:
      address += 1
      return address, address
    else:
      address_left, address_right = _buildtree(address, depth - 1)
      _, address_right = _buildtree(address_right, depth - 1)
      instruction.append((address_left, address_right))
      return address_left, address_right

  instruction = []
  _, _ = _buildtree(init_memory, max_depth)
  return np.array(instruction, dtype=np.int32)
Run build tree and output the u turn checking input instruction.
Run build tree and output the u turn checking input instruction.
Run build tree and output the u turn checking input instruction .
def build_tree_uturn_instruction(max_depth, init_memory=0):
  def _buildtree(address, depth):
    if depth == 0:
      address += 1
      return address, address
    else:
      address_left, address_right = _buildtree(address, depth - 1)
      _, address_right = _buildtree(address_right, depth - 1)
      instruction.append((address_left, address_right))
      return address_left, address_right
  instruction = []
  _, _ = _buildtree(init_memory, max_depth)
  return np.array(instruction, dtype=np.int32)
def build_tree_uturn_instruction ( max_depth , init_memory = 0 ) : def _buildtree ( address , depth ) : if depth == 0 : address += 1 return address , address else : address_left , address_right = _buildtree ( address , depth - 1 ) _ , address_right = _buildtree ( address_right , depth - 1 ) instruction . append ( ( address_left , address_right ) ) return address_left , address_right instruction = [ ] _ , _ = _buildtree ( init_memory , max_depth ) return np . array ( instruction , dtype = np . int32 )
Run build tree and output the u turn checking input instruction.
Run build tree and output the u turn checking input instruction .
"""Run build tree and output the u turn checking input instruction."""
max_depth
init_memory