# UnknownError when Training

**URL:** <https://community.deeplearning.ai/t/unknownerror-when-training/144513>\
**Category:** Convolutional Neural Networks in TensorFlow\
**Tags:** week-module-1\
**Created:** [June 21, 2022, 10:36pm UTC](https://community.deeplearning.ai/t/unknownerror-when-training/144513 "2022-06-21T22:36:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Zhen](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@Alex\_Zhen](https://community.deeplearning.ai/u/Alex_Zhen)\
**Post date:** [June 21, 2022, 10:36pm UTC](https://community.deeplearning.ai/t/unknownerror-when-training/144513/1 "2022-06-21T22:36:41Z")

</div>

This is the error I am getting when trying to train my model. I am not sure how to interpret this.

UnknownError: Graph execution error:

2 root error(s) found.  
(0) UNKNOWN: UnidentifiedImageError: cannot identify image file \<\_io.BytesIO object at 0x7f487ae83e90\>  
Traceback (most recent call last):

File “/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/script\_ops.py”, line 271, in **call**  
ret = func(\*args)

File “/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py”, line 642, in wrapper  
return func(\*args, \*\*kwargs)

File “/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/ops/dataset\_ops.py”, line 1004, in generator\_py\_func  
values = next(generator\_state.get\_iterator(iterator\_id))

File “/usr/local/lib/python3.7/dist-packages/keras/engine/data\_adapter.py”, line 830, in wrapped\_generator  
for data in generator\_fn():

File “/usr/local/lib/python3.7/dist-packages/keras/engine/data\_adapter.py”, line 956, in generator\_fn  
yield x[i]

File “/usr/local/lib/python3.7/dist-packages/keras\_preprocessing/image/iterator.py”, line 65, in **getitem**  
return self.\_get\_batches\_of\_transformed\_samples(index\_array)

File “/usr/local/lib/python3.7/dist-packages/keras\_preprocessing/image/iterator.py”, line 230, in \_get\_batches\_of\_transformed\_samples  
interpolation=self.interpolation)

File “/usr/local/lib/python3.7/dist-packages/keras\_preprocessing/image/utils.py”, line 114, in load\_img  
img = pil\_image.open(io.BytesIO(f.read()))

File “/usr/local/lib/python3.7/dist-packages/PIL/Image.py”, line 2896, in open  
"cannot identify image file r" (filename if filename else fp)

PIL.UnidentifiedImageError: cannot identify image file \<\_io.BytesIO object at 0x7f487ae83e90\>

```
 [[{{node PyFunc}}]]
 [[IteratorGetNext]]
 [[IteratorGetNext/_4]]

```

(1) UNKNOWN: UnidentifiedImageError: cannot identify image file \<\_io.BytesIO object at 0x7f487ae83e90\>  
Traceback (most recent call last):

File “/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/script\_ops.py”, line 271, in **call**  
ret = func(\*args)

File “/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py”, line 642, in wrapper  
return func(\*args, \*\*kwargs)

File “/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/ops/dataset\_ops.py”, line 1004, in generator\_py\_func  
values = next(generator\_state.get\_iterator(iterator\_id))

File “/usr/local/lib/python3.7/dist-packages/keras/engine/data\_adapter.py”, line 830, in wrapped\_generator  
for data in generator\_fn():

File “/usr/local/lib/python3.7/dist-packages/keras/engine/data\_adapter.py”, line 956, in generator\_fn  
yield x[i]

File “/usr/local/lib/python3.7/dist-packages/keras\_preprocessing/image/iterator.py”, line 65, in **getitem**  
return self.\_get\_batches\_of\_transformed\_samples(index\_array)

File “/usr/local/lib/python3.7/dist-packages/keras\_preprocessing/image/iterator.py”, line 230, in \_get\_batches\_of\_transformed\_samples  
interpolation=self.interpolation)

File “/usr/local/lib/python3.7/dist-packages/keras\_preprocessing/image/utils.py”, line 114, in load\_img  
img = pil\_image.open(io.BytesIO(f.read()))

File “/usr/local/lib/python3.7/dist-packages/PIL/Image.py”, line 2896, in open  
"cannot identify image file r" (filename if filename else fp)

PIL.UnidentifiedImageError: cannot identify image file \<\_io.BytesIO object at 0x7f487ae83e90\>

```
 [[{{node PyFunc}}]]
 [[IteratorGetNext]]

```

0 successful operations.  
0 derived errors ignored. [Op:\_\_inference\_train\_function\_17012]

---

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [June 22, 2022, 5:26am UTC](https://community.deeplearning.ai/t/unknownerror-when-training/144513/2 "2022-06-22T05:26:06Z")

</div>

The training data and validation data should not contain any files that are 0 in size. These 2 files should be filtered out when creating training / validation data:

```auto
666.jpg is zero length, so ignoring.
11702.jpg is zero length, so ignoring.

```

---

<div class="post-metadata">

**Author:** ![Alex\_Zhen](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@Alex\_Zhen](https://community.deeplearning.ai/u/Alex_Zhen)\
**Post date:** [June 29, 2022, 1:00am UTC](https://community.deeplearning.ai/t/unknownerror-when-training/144513/3 "2022-06-29T01:00:06Z")

</div>

Thank you. Missed that instruction
