Skip to content

Instantly share code, notes, and snippets.

@alexbrillant
Last active October 18, 2020 23:39
Show Gist options
  • Save alexbrillant/c9ccb2195f228173a98130a49959271a to your computer and use it in GitHub Desktop.
Save alexbrillant/c9ccb2195f228173a98130a49959271a to your computer and use it in GitHub Desktop.
def generator():
for factor in np.arange(0.5, 1, 0.01):
time = np.arange(0, 50, 0.2)
sin: np.ndarray = np.sin(factor * time) + np.random.normal(scale=0.25, size=len(time))
yield sin[:25], sin[25:]
time_steps = 25
input_dim = 1
output_dim = 1
dataset = tf.data.Dataset.from_generator(
generator=generator,
output_types=(tf.float32, tf.float32),
output_shapes=(
tf.TensorShape([None, time_steps, input_dim]), # x output shape
tf.TensorShape([None, time_steps, output_dim]) # y output shape
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment