# Convolutional Neural Network W4A1

**URL:** <https://community.deeplearning.ai/t/convolutional-neural-network-w4a1/278797>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [February 22, 2023, 11:57am UTC](https://community.deeplearning.ai/t/convolutional-neural-network-w4a1/278797 "2023-02-22T11:57:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cihatkaya\_ck](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@cihatkaya\_ck](https://community.deeplearning.ai/u/cihatkaya_ck)\
**Post date:** [February 22, 2023, 11:57am UTC](https://community.deeplearning.ai/t/convolutional-neural-network-w4a1/278797/1 "2023-02-22T11:57:24Z")

</div>

Hello. When I tried the W4A1 th assignment of the Convolutional Neural Network course on my own computer, in the following model\_from\_json code:

> from tensorflow.keras.models import model\_from\_json
> 
> json\_file = open(‘keras-facenet-h5/model.json’, ‘r’)  
> loaded\_model\_json = json\_file.read()  
> json\_file.close()  
> model = model\_from\_json(loaded\_model\_json)  
> model.load\_weights(‘keras-facenet-h5/model.h5’)

I get this error:

> ValueError: bad marshal data (unknown type code)

How can i solve this.  
Thanks

---

<div class="post-metadata">

**Author:** ![ai\_curious](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/ai_curious/32/128003_2.png) [@ai\_curious](https://community.deeplearning.ai/u/ai_curious)\
**Post date:** [February 22, 2023, 1:17pm UTC](https://community.deeplearning.ai/t/convolutional-neural-network-w4a1/278797/2 "2023-02-22T13:17:16Z")

</div>

You should first compare python versions of the two environments. Likely your local is newer (eg Python 3.x) and incorporates a non-backwards compatible change. One fix is to use virtual environments to run locally so you can match the release level of the modules that run the code successfully (eg Python 2.x).

---

<div class="post-metadata">

**Author:** ![Mubsi](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/mubsi/32/94983_2.png) [@Mubsi](https://community.deeplearning.ai/u/Mubsi)\
**Post date:** [February 22, 2023, 3:32pm UTC](https://community.deeplearning.ai/t/convolutional-neural-network-w4a1/278797/3 "2023-02-22T15:32:51Z")

</div>

To add on what ai\_curious mentioned, check the compatibility of the python version and the TF version. Ideally, you should be using the versions that are on Coursera.

---

<div class="post-metadata">

**Author:** ![ai\_curious](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/ai_curious/32/128003_2.png) [@ai\_curious](https://community.deeplearning.ai/u/ai_curious)\
**Post date:** [February 22, 2023, 3:57pm UTC](https://community.deeplearning.ai/t/convolutional-neural-network-w4a1/278797/4 "2023-02-22T15:57:45Z")

</div>

> [@Mubsi](#):
>
> Ideally, you should be using the versions that are on Coursera.

Good advice for the entire environment, not just the several explicitly mentioned already in this thread.

However, specifically for the marshal error…

> **[marshal — Internal Python object serialization](https://docs.python.org/3/library/marshal.html)**
>
> This module contains functions that can read and write Python values in a binary format. The format is specific to Python, but independent of machine architecture issues (e.g., you can write a Pyth...

Details of the format are undocumented on purpose; it may change between Python versions (although it rarely does). [1](https://docs.python.org/3/library/marshal.html#id2)

This is not a general “persistence” module. For general persistence and transfer of Python objects through RPC calls, see the modules [`pickle`](https://docs.python.org/3/library/pickle.html#module-pickle) and [`shelve`](https://docs.python.org/3/library/shelve.html#module-shelve). The [`marshal`](https://docs.python.org/3/library/marshal.html#module-marshal) module exists mainly to support reading and writing the “pseudo-compiled” code for Python modules of `.pyc` files. _ **Therefore, the Python maintainers reserve the right to modify the marshal format in backward incompatible ways should the need arise.** _

_ **My emphasis added** _

Which is why I believe Python the culprit here. Cheers
