-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
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
There was a problem hiding this 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!
tf_keras/utils/timeseries_dataset.py
Outdated
input_data = data[:-10] | ||
targets = data[10:] | ||
data = tf.range(15) | ||
sequence_length =10 |
There was a problem hiding this comment.
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)
Hi @SuryanarayanaY Can you please check @grasskin's comments ? Thank you! |
Done changes for black formatting.
Done the changes for black formatting.Please review. |
Hi @grasskin Can you please review this PR ? Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
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
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
assequence_length
here. Though the intention in the example is to demo on generating batches of data using the API,Its better to useinput_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!