# Model\_load\_json

**URL:** <https://community.deeplearning.ai/t/model-load-json/298417>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [March 28, 2023, 7:26pm UTC](https://community.deeplearning.ai/t/model-load-json/298417 "2023-03-28T19:26:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Areeg\_Fahad](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Areeg\_Fahad](https://community.deeplearning.ai/u/Areeg_Fahad)\
**Post date:** [March 28, 2023, 7:26pm UTC](https://community.deeplearning.ai/t/model-load-json/298417/1 "2023-03-28T19:26:02Z")

</div>

I want to implement Facenet on my laptop, but when I load the model, I get an error. I have already downloaded the model.json file, but I don’t know what the error is.

 ![image](https://global.discourse-cdn.com/dlai/original/3X/1/f/1fc79f5632785e61de121244b8c903d8e23779f9.png)  
 ![image](https://global.discourse-cdn.com/dlai/original/3X/0/c/0cfa59a3995924ccc71e15cdb9e9485782c0d4e0.png)

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [March 28, 2023, 7:35pm UTC](https://community.deeplearning.ai/t/model-load-json/298417/2 "2023-03-28T19:35:17Z")

</div>

Does that same code work if you run it on the course website? The reason I ask is that one thing to check is that this is not a version incompatibility issue with TF. The course runs a pretty old version of TF in most of the notebooks (2.3), although some of them were recently upgraded to 2.9.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [March 28, 2023, 7:43pm UTC](https://community.deeplearning.ai/t/model-load-json/298417/3 "2023-03-28T19:43:14Z")

</div>

Note that the code that does that in the Face Recognition assignment looks a bit different:

```auto
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')

```

So why did you make those changes? Why use TF v1? Most people think “eager mode” is a big win. 🤓

The other major thing to note there is that the course notebook uses a local copy of the model JSON file, whereas you are using the version loaded directly from Keras.

---

<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:** [March 28, 2023, 8:40pm UTC](https://community.deeplearning.ai/t/model-load-json/298417/4 "2023-03-28T20:40:54Z")

</div>

Hi @Areeg_Fahad ,

To add on top of what Paul mentioned, `bad Marshall error` occurs when there is incompatibility issues, as in, the assignment that is on Coursera uses specific python and TF version, which I believe is different than the one you are using.

Also, the model, either the one on coursera or keras, have been trained and saved using specific TF versions and they can’t really be used with another version. I believe the assignment model was done using TF 2.4, so you can’t really load it with latest TF version, or as Paul suspects you are using, with TF v1.

Additionally, another thing to keep in mind is, even if you load TF v1 version from keras, all other library packages and python versions should be the same or closer to as the ones which were used for the model.

Best,  
Mubsi

---

<div class="post-metadata">

**Author:** ![saifkhanengr](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/saifkhanengr/32/152858_2.png) [@saifkhanengr](https://community.deeplearning.ai/u/saifkhanengr)\
**Post date:** [March 29, 2023, 12:05am UTC](https://community.deeplearning.ai/t/model-load-json/298417/5 "2023-03-29T00:05:42Z")

</div>

Hello @Areeg_Fahad! Yes, bad marshal error is very bad and occurs when we have compatibility issue. Our mentor Raymond discussed alternate way [here](https://community.deeplearning.ai/t/running-course-4-week-4-face-recognition-programming-assignment-notebook-offline/289984/19).

Best,  
Saif.

---

<div class="post-metadata">

**Author:** ![Areeg\_Fahad](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Areeg\_Fahad](https://community.deeplearning.ai/u/Areeg_Fahad)\
**Post date:** [March 29, 2023, 7:46am UTC](https://community.deeplearning.ai/t/model-load-json/298417/6 "2023-03-29T07:46:10Z")

</div>

It worked perfectly. Thank you. @saifkhanengr🙏

---

<div class="post-metadata">

**Author:** ![saifkhanengr](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/saifkhanengr/32/152858_2.png) [@saifkhanengr](https://community.deeplearning.ai/u/saifkhanengr)\
**Post date:** [March 29, 2023, 10:29am UTC](https://community.deeplearning.ai/t/model-load-json/298417/7 "2023-03-29T10:29:14Z")

</div>

I am glad it worked for you…
