Hello, I am having an issue with this assignment, I wonder if someone could help me, please:
Site demanded Info:
- Week 2.
- Link to the classroom item: Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera
- Description:
I tried to complete the Week 2 Exercise 2, following the instructions, and apparenty on Coursera’s Jupyter Notebook everything seems to work, but, once I submit, I get a 0/100, with the next Grader output
Cell #5. Can't compile the student's code. Error: InvalidArgumentError()
Which I assume refers to the “Step 3 - Shuffle and map the new batches” section’s 2nd cell (5th).
I followed the checker mentioned here by Chris Favila, and I also print before the type for the batches, and both apparently have the expected output:
# print(type(train_batches))
<class 'tensorflow.python.data.ops.dataset_ops.MapDataset'>
# Chris Favila's checker...
<class 'dict'>
3
dict_keys(['image', 'image/filename', 'label'])
To debug, in teh (optional) Step 5, I enabled the training cell, and I get the following error:
Epoch 1/3
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
Input In [8], in <cell line: 11>()
6 # Train it for a number of epochs. You should not need many (max 5)
7 # Train on the train_batches, and validation on the validation_batches
9 EPOCHS = 3 # YOUR CODE HERE
---> 11 history = model.fit(train_batches, epochs=EPOCHS, validation_data=validation_batches,verbose=1)
13 model.summary()
File /usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py:67, in filter_traceback.<locals>.error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.__traceback__)
---> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb
File /usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/execute.py:54, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
52 try:
53 ctx.ensure_initialized()
---> 54 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
55 inputs, attrs, num_outputs)
56 except core._NotOkStatusException as e:
57 if name is not None:
InvalidArgumentError: Graph execution error:
Detected at node 'IteratorGetNext' defined at (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
...
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1039, in step_function
data = next(iterator)
Node: 'IteratorGetNext'
Detected at node 'IteratorGetNext' defined at (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
...
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1039, in step_function
data = next(iterator)
Node: 'IteratorGetNext'
2 root error(s) found.
(0) INVALID_ARGUMENT: Cannot batch tensors with different shapes in component 0. First element had shape [365,500,3] and element 1 had shape [427,500,3].
[[{{node IteratorGetNext}}]]
[[IteratorGetNext/_2]]
(1) INVALID_ARGUMENT: Cannot batch tensors with different shapes in component 0. First element had shape [365,500,3] and element 1 had shape [427,500,3].
[[{{node IteratorGetNext}}]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_36568]
I wonder if I am applying wrongly the format_image
function, or maybe downloading the dataset with some wrong parameter…
For the download, I use:
- the name with the given name + version number: ‘cats_vs_dogs:4..’,
- download set to true or not set at all gives the same result and error,
- data dir set to filePath,
- with info enabled, and
- the splits as demanded (numbers match)…
- Moreover, I tried to enable as supervised, but it just generated errors in
format_image()
, indeed, for what I can read on the same thread Chris Favila answered with his checker code, this option I think should not be enabled…
Do you have some idea, please, as I am a bit lost?
Note: I opened the Notebook yesterday for first time directly from Exercise 2’s “Launch Notebook” button from Coursera, so, I assume it is the last version (following comments in this thread)