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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SuryanarayanaY
Copy link
Collaborator

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
Collaborator 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!

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.

None yet

4 participants