Skip to content

Commit

Permalink
Merge pull request #14 from SuryanarayanaY:patch-1
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 657260721
  • Loading branch information
tensorflower-gardener committed Jul 29, 2024
2 parents 8eb5627 + baa074b commit 1b08597
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tf_keras/utils/timeseries_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,24 @@ def timeseries_dataset_from_array(
timesteps to predict the next timestep, you would use:
```python
input_data = data[:-10]
targets = data[10:]
data = tf.range(15)
sequence_length = 10
input_data = data[:]
targets = data[sequence_length:]
dataset = tf.keras.utils.timeseries_dataset_from_array(
input_data, targets, sequence_length=10)
input_data, targets, sequence_length=sequence_length
)
for batch in dataset:
inputs, targets = batch
assert np.array_equal(inputs[0], data[:10]) # First sequence: steps [0-9]
# First sequence: steps [0-9]
assert np.array_equal(inputs[0], data[:sequence_length])
# Corresponding target: step 10
assert np.array_equal(targets[0], data[10])
assert np.array_equal(targets[0], data[sequence_length])
break
# To view the generated dataset
for batch in dataset.as_numpy_iterator():
input, label = batch
print(f"Input:{input}, target:{label}")
```
Example 3: Temporal regression for many-to-many architectures.
Expand Down

0 comments on commit 1b08597

Please sign in to comment.