Skip to content

Instantly share code, notes, and snippets.

View alexbrillant's full-sized avatar
🎯
Focusing

Alexandre Brillant alexbrillant

🎯
Focusing
  • Québec, Canada
View GitHub Profile
time_steps = 50
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]), tf.TensorShape([None, time_steps, output_dim]))
)
model.compile(
optimizer=Adam(),
loss='mean_squared_error'
)
epochs = 25
log_dir='logs'
model.fit(
train_data, # train dataset that yields (x, y) tuples
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