class_docstr: A layer outputting reward predictions using K bins and two-hot encoding.
  
  This layer is used in two models in DreamerV3: The reward predictor of the world
  model and the value function. K is 255 by default (see [1]) and doesn't change
  with the model size.
  
  Possible predicted reward/values range from symexp(-20.0) to symexp(20.0), which
  should cover any possible environment. Outputs of this layer are generated by
  generating logits/probs via a single linear layer, then interpreting the probs
  as weights for a weighted average of the different possible reward (binned) values.
class_docstr_tok: ["A","layer","outputting","reward","predictions","using","K","bins","and","two-hot","encoding",".","This","layer","is","used","in","two","models","in","DreamerV3",":","The","reward","predictor","of","the","world","model","and","the","value","function",".","K","is","255","by","default","(","see","[","1","]",")","and","does","n't","change","with","the","model","size",".","Possible","predicted","reward\/values","range","from","symexp","(","-20.0",")","to","symexp","(","20.0",")",",","which","should","cover","any","possible","environment",".","Outputs","of","this","layer","are","generated","by","generating","logits\/probs","via","a","single","linear","layer",",","then","interpreting","the","probs","as","weights","for","a","weighted","average","of","the","different","possible","reward","(","binned",")","values","."]
docstr: Initializes a RewardPredictorLayer instance.
  
  Args:
      num_buckets: The number of buckets to create. Note that the number of
          possible symlog'd outcomes from the used distribution is
          `num_buckets` + 1:
          lower_bound --bucket-- o[1] --bucket-- o[2] ... --bucket-- upper_bound
          o=outcomes
          lower_bound=o[0]
          upper_bound=o[num_buckets]
      lower_bound: The symlog'd lower bound for a possible reward value.
          Note that a value of -20.0 here already allows individual (actual env)
          rewards to be as low as -400M. Buckets will be created between
          `lower_bound` and `upper_bound`.
      upper_bound: The symlog'd upper bound for a possible reward value.
          Note that a value of +20.0 here already allows individual (actual env)
          rewards to be as high as 400M. Buckets will be created between
          `lower_bound` and `upper_bound`.
docstr_tok: ["Initializes","a","RewardPredictorLayer","instance",".","Args",":","num_buckets",":","The","number","of","buckets","to","create",".","Note","that","the","number","of","possible","symlog","'d","outcomes","from","the","used","distribution","is","`","num_buckets","`","+","1",":","lower_bound","--","bucket","--","o","[","1","]","--","bucket","--","o","[","2","]","...","--","bucket","--","upper_bound","o=outcomes","lower_bound=o","[","0","]","upper_bound=o","[","num_buckets","]","lower_bound",":","The","symlog","'d","lower","bound","for","a","possible","reward","value",".","Note","that","a","value","of","-20.0","here","already","allows","individual","(","actual","env",")","rewards","to","be","as","low","as","-400M",".","Buckets","will","be","created","between","`","lower_bound","`","and","`","upper_bound","`",".","upper_bound",":","The","symlog","'d","upper","bound","for","a","possible","reward","value",".","Note","that","a","value","of","+20.0","here","already","allows","individual","(","actual","env",")","rewards","to","be","as","high","as","400M",".","Buckets","will","be","created","between","`","lower_bound","`","and","`","upper_bound","`","."]
code: def __init__(
      self,
      *,
      num_buckets: int = 255,
      lower_bound: float = -20.0,
      upper_bound: float = 20.0,
      trainable: bool = True,
  ):
      """Initializes a RewardPredictorLayer instance.
  
      Args:
          num_buckets: The number of buckets to create. Note that the number of
              possible symlog'd outcomes from the used distribution is
              `num_buckets` + 1:
              lower_bound --bucket-- o[1] --bucket-- o[2] ... --bucket-- upper_bound
              o=outcomes
              lower_bound=o[0]
              upper_bound=o[num_buckets]
          lower_bound: The symlog'd lower bound for a possible reward value.
              Note that a value of -20.0 here already allows individual (actual env)
              rewards to be as low as -400M. Buckets will be created between
              `lower_bound` and `upper_bound`.
          upper_bound: The symlog'd upper bound for a possible reward value.
              Note that a value of +20.0 here already allows individual (actual env)
              rewards to be as high as 400M. Buckets will be created between
              `lower_bound` and `upper_bound`.
      """
      self.num_buckets = num_buckets
      super().__init__(name=f"reward_layer_{self.num_buckets}buckets")
  
      self.lower_bound = lower_bound
      self.upper_bound = upper_bound
      self.reward_buckets_layer = tf.keras.layers.Dense(
          units=self.num_buckets,
          activation=None,
          # From [1]:
          # "We further noticed that the randomly initialized reward predictor and
          # critic networks at the start of training can result in large predicted
          # rewards that can delay the onset of learning. We initialize the output
          # weights of the reward predictor and critic to zeros, which effectively
          # alleviates the problem and accelerates early learning."
          kernel_initializer="zeros",
          bias_initializer="zeros",  # zero-bias is default anyways
          trainable=trainable,
      )
  
imports: from ray.rllib.utils.framework import try_import_tf
label_desc: Use image node_id 1 to create a new RewardPredictorLayer object from inherited base classes: tf.keras.layers with example: obj = RewardPredictorLayer()