Problem & suggested fix in beginner tutorials - Loading Image Data
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- r, tensorflow
- Domain
- documentation, machine-learning
Research direction
Start with the linked “Load using tf.data” tutorial and inspect the get_label function and its tf$strings$split call. Reproduce the labeled_ds error, verify the path separator correction, and confirm that the tutorial runs without the slice-index failure.
Written by the indexing model from the issue text.
Description
Hi Team,
TLDR:
Please check the change in instruction from "/" to "\\" :
get_label <- function(file_path) {
parts <- tf$strings$split(file_path, "/")
parts[-2] %>%
tf$equal(classes) %>%
tf$cast(dtype = tf$float32)
}
Longer:
I was recently going through the loading image dataset tutorial, and got the following error when applying the below code:
Code:
# num_parallel_calls are going to be autotuned
labeled_ds <- list_ds %>% dataset_map(preprocess_path, num_parallel_calls = tf$data$experimental$AUTOTUNE)
Error:
2022-04-09 12:16:47.207451: W tensorflow/core/framework/op_kernel.cc:1745] OP_REQUIRES failed at strided_slice_op.cc:108 : INVALID_ARGUMENT: slice index -1 of dimension 0 out of bounds.
Error in py_iter_next(it, completed) :
InvalidArgumentError: {{function_node __wrapped__IteratorGetNext_output_types_2_device_/job:localhost/replica:0/task:0/device:CPU:0}} slice index -1 of dimension 0 out of bounds.
[[{{node strided_slice}}]] [Op:IteratorGetNext]
After a bit of tinkering, I found that the get_label function was not splitting the directory path correctly. This resulted in the data_map function not being able to function correctly. This was because the file path containing the category was not being plit through tf$strings$split (split) and hence couldn't be compared through tf$equal(classes). Thus, the sep value of / was causing the error. Please see the TLDR section for the suggested fix.
- Dominant language
- R
- Stars
- 1.3k
- Forks
- 316
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rstudio/tensorflow
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
rstudio/tensorflow#625 · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
rstudio/tensorflow#622 · 7 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
rstudio/tensorflow#620 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
rstudio/tensorflow#611 · 4 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
rstudio/tensorflow#605 · 2 comments ·
All issues in rstudio/tensorflow
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·