tensorflow_probability/python/sts/seasonal.py
def build_is_last_day_of_season(num_steps_per_season):
  """Build utility method to compute whether the season is changing."""
  num_steps_per_cycle = np.sum(num_steps_per_season)
  changepoints = np.cumsum(np.ravel(num_steps_per_season)) - 1
  def is_last_day_of_season(t):
    t_ = dist_util.maybe_get_static_value(t)
    if t_ is not None:  # static case
      step_in_cycle = t_ % num_steps_per_cycle
      return any(step_in_cycle == changepoints)
    else:
      step_in_cycle = tf.math.floormod(t, num_steps_per_cycle)
      return tf.reduce_any(
          input_tensor=tf.equal(step_in_cycle, changepoints))
  return is_last_day_of_season
def build_is_last_day_of_season(num_steps_per_season):
  num_steps_per_cycle = np.sum(num_steps_per_season)
  changepoints = np.cumsum(np.ravel(num_steps_per_season)) - 1
  def is_last_day_of_season(t):
    t_ = dist_util.maybe_get_static_value(t)
    if t_ is not None:  # static case
      step_in_cycle = t_ % num_steps_per_cycle
      return any(step_in_cycle == changepoints)
    else:
      step_in_cycle = tf.math.floormod(t, num_steps_per_cycle)
      return tf.reduce_any(
          input_tensor=tf.equal(step_in_cycle, changepoints))
  return is_last_day_of_season
def build_is_last_day_of_season ( num_steps_per_season ) : num_steps_per_cycle = np . sum ( num_steps_per_season ) changepoints = np . cumsum ( np . ravel ( num_steps_per_season ) ) - 1 def is_last_day_of_season ( t ) : t_ = dist_util . maybe_get_static_value ( t ) if t_ is not None : # static case step_in_cycle = t_ % num_steps_per_cycle return any ( step_in_cycle == changepoints ) else : step_in_cycle = tf . math . floormod ( t , num_steps_per_cycle ) return tf . reduce_any ( input_tensor = tf . equal ( step_in_cycle , changepoints ) ) return is_last_day_of_season
Build utility method to compute whether the season is changing.
Build utility method to compute whether the season is changing .