Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example code in timeseries_dataset.py #14

Merged
merged 3 commits into from
Jul 29, 2024

Conversation

SuryanarayanaY
Copy link
Contributor

I have gone through the example-2 in the TF documentation of keras.utils.timeseries_dataset_from_array. With existing code we can only generate one batch of dataset.In TF forum one of the user raised concern that users may confuse why we are using input_data = data[:-10] as it can generate only one batch and there will be loss of data and users may confuse -10 as sequence_length here. Though the intention in the example is to demo on generating batches of data using the API,Its better to use input_data = data[:] to avoid confusion and also it give correct demo to generate the total possible no of batches without loss of data.

Also I am adding the sequence_length as variable in the code to avoid hard coding in the data indexing which will make it better understandable.

Thanks!

I have gone through the example-2 in the TF documentation of keras.utils.timeseries_dataset_from_array. With existing code we can only generate one batch of dataset.In TF forum one of the user raised concern that users may confuse why we are using input_data = data[:-10] as it can generate only one batch and there will be loss of data. Though the intention in the example is to demo on generating batches of data using the API,Its better to use input_data = data[:] to avoid confusion and also it give perfect demo to generate the total possible no of batches without loss of data.

Also I am adding the sequence_length as variable in the code to avoid hard coding in the data indexing which will make it better understandable.

Thanks!
Fixed the lint errors
Copy link
Member

@grasskin grasskin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think overall it's a helpful change - thank you for the PR!

input_data = data[:-10]
targets = data[10:]
data = tf.range(15)
sequence_length =10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to run the formatter (add a space before 10)

@gbaned
Copy link

gbaned commented Oct 31, 2023

Hi @SuryanarayanaY Can you please check @grasskin's comments ? Thank you!

Done changes for black formatting.
@SuryanarayanaY
Copy link
Contributor Author

Done the changes for black formatting.Please review.

@gbaned
Copy link

gbaned commented Jan 8, 2024

Hi @grasskin Can you please review this PR ? Thank you!

Copy link
Member

@grasskin grasskin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@sachinprasadhs sachinprasadhs added the ready to pull Ready to be merged into the codebase label Jul 29, 2024
copybara-service bot pushed a commit that referenced this pull request Jul 29, 2024
Imported from GitHub PR #14

I have gone through the example-2 in the TF documentation of [keras.utils.timeseries_dataset_from_array](https://www.tensorflow.org/api_docs/python/tf/keras/utils/timeseries_dataset_from_array). With existing code we can only generate one batch of dataset.In TF forum one of the user raised concern that users may confuse why we are using `input_data = data[:-10]` as it can generate only one batch and there will be loss of data and users may confuse `-10` as `sequence_length` here. Though the intention in the example is to demo on generating batches of data using the API,Its better to use `input_data = data[:]` to avoid confusion and also it give correct demo to generate the total possible no of batches without loss of data.

Also I am adding the `sequence_length` as variable in the code to avoid hard coding in the data indexing which will make it better understandable.

Thanks!
Copybara import of the project:

--
84651ad by Surya <[email protected]>:

Update example code in timeseries_dataset.py

I have gone through the example-2 in the TF documentation of keras.utils.timeseries_dataset_from_array. With existing code we can only generate one batch of dataset.In TF forum one of the user raised concern that users may confuse why we are using input_data = data[:-10] as it can generate only one batch and there will be loss of data. Though the intention in the example is to demo on generating batches of data using the API,Its better to use input_data = data[:] to avoid confusion and also it give perfect demo to generate the total possible no of batches without loss of data.

Also I am adding the sequence_length as variable in the code to avoid hard coding in the data indexing which will make it better understandable.

Thanks!
--
e8da674 by Surya <[email protected]>:

Update timeseries_dataset.py

Fixed the lint errors
--
baa074b by Surya <[email protected]>:

Update formatting errors timeseries_dataset.py

Done changes for black formatting.

Merging this change closes #14

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14 from SuryanarayanaY:patch-1 baa074b
PiperOrigin-RevId: 657250344
@copybara-service copybara-service bot merged commit 1b08597 into keras-team:master Jul 29, 2024
4 checks passed
@github-actions github-actions bot removed the ready to pull Ready to be merged into the codebase label Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants