[go: nahoru, domu]

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

Problem & suggested fix in beginner tutorials - Loading Image Data #525

Open
jonathannathanaus opened this issue Apr 9, 2022 · 0 comments

Comments

@jonathannathanaus
Copy link

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.

@jonathannathanaus jonathannathanaus changed the title Problem in beginner tutorials Problem & suggested fix in beginner tutorials - Loading Image Data Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant