tf_agents.bandits.multi_objective.multi_objective_scalarizer.ScalarizerTraceType

Stay organized with collections Save and categorize content based on your preferences.

Class outlining the default Tracing Protocol for Scalarizer.

If included as an argument, corresponding tf.function will always retrace for each usage.

Derived classes can override this behavior by specifying their own Tracing Protocol.

Methods

is_subtype_of

View source

Returns True if self is a subtype of other.

For example, tf.function uses subtyping for dispatch: if a.is_subtype_of(b) is True, then an argument of TraceType a can be used as argument to a ConcreteFunction traced with an a TraceType b.

Args
other A TraceType object to be compared against.

Example:

class Dimension(TraceType):
  def __init__(self, value: Optional[int]):
    self.value = value

  def is_subtype_of(self, other):
    # Either the value is the same or other has a generalized value that
    # can represent any specific ones.
    return (self.value == other.value) or (other.value is None)

most_specific_common_supertype

View source

Returns the most specific supertype of self and others, if exists.

The returned TraceType is a supertype of self and others, that is, they are all subtypes (see is_subtype_of) of it. It is also most specific, that is, there it has no subtype that is also a common supertype of self and others.

If self and others have no common supertype, this returns None.

Args
others A sequence of TraceTypes.

Example:

 class Dimension(TraceType):
   def __init__(self, value: Optional[int]):
     self.value = value

   def most_specific_common_supertype(self, other):
      # Either the value is the same or other has a generalized value that
      # can represent any specific ones.
      if self.value == other.value:
        return self.value
      else:
        return Dimension(None)

__eq__

View source

Return self==value.