(
    batch_size=gin.REQUIRED,
    length=gin.REQUIRED,
    max_phase=(2 * math.pi),
    min_period=0.1,
    max_period=10.0,
)
return Inputs(train_stream=random_minibatches, eval_stream=random_minibatches)
Sinusoids of random period and phase.

  Args:
    batch_size (int): Number of examples in a batch.
    length (int): Length of each sequence.
    max_phase (float): Maximum phase of the sinusoids.
    min_period (float): Minimum period of the sinusoids.
    max_period (float): Maximum period of the sinusoids.

  Returns:
    trax.inputs.Inputs
Sinusoids of random period and phase.
Sinusoids of random period and phase .
def sine_inputs(
    batch_size=gin.REQUIRED,
    length=gin.REQUIRED,
    max_phase=(2 * math.pi),
    min_period=0.1,
    max_period=10.0,
):
  """Sinusoids of random period and phase.

  Args:
    batch_size (int): Number of examples in a batch.
    length (int): Length of each sequence.
    max_phase (float): Maximum phase of the sinusoids.
    min_period (float): Minimum period of the sinusoids.
    max_period (float): Maximum period of the sinusoids.

  Returns:
    trax.inputs.Inputs
  """
  def random_series():
    while True:
      phase = np.random.uniform(0, max_phase)
      period = np.exp(np.random.uniform(np.log(min_period), np.log(max_period)))
      x = np.arange(length)
      yield np.sin((x - phase) / period)

  def random_minibatches(_):
    minibatch = []
    for series in random_series():
      minibatch.append(series)
      if len(minibatch) == batch_size:
        obs = np.stack(minibatch)
        minibatch.clear()
        act = np.zeros_like(obs, dtype=np.int32)
        mask = np.ones_like(obs)
        yield (obs, act, obs, mask)

  return Inputs(train_stream=random_minibatches, eval_stream=random_minibatches)
def sine_inputs ( batch_size = gin . REQUIRED , length = gin . REQUIRED , max_phase = ( 2 * math . pi ) , min_period = 0.1 , max_period = 10.0 , ) : def random_series ( ) : while True : phase = np . random . uniform ( 0 , max_phase ) period = np . exp ( np . random . uniform ( np . log ( min_period ) , np . log ( max_period ) ) ) x = np . arange ( length ) yield np . sin ( ( x - phase ) / period ) def random_minibatches ( _ ) : minibatch = [ ] for series in random_series ( ) : minibatch . append ( series ) if len ( minibatch ) == batch_size : obs = np . stack ( minibatch ) minibatch . clear ( ) act = np . zeros_like ( obs , dtype = np . int32 ) mask = np . ones_like ( obs ) yield ( obs , act , obs , mask ) return Inputs ( train_stream = random_minibatches , eval_stream = random_minibatches )