• <i id='He26q'><tr id='He26q'><dt id='He26q'><q id='He26q'><span id='He26q'><b id='He26q'><form id='He26q'><ins id='He26q'></ins><ul id='He26q'></ul><sub id='He26q'></sub></form><legend id='He26q'></legend><bdo id='He26q'><pre id='He26q'><center id='He26q'></center></pre></bdo></b><th id='He26q'></th></span></q></dt></tr></i><div id='He26q'><tfoot id='He26q'></tfoot><dl id='He26q'><fieldset id='He26q'></fieldset></dl></div>

        <tfoot id='He26q'></tfoot>

        <small id='He26q'></small><noframes id='He26q'>

        • <bdo id='He26q'></bdo><ul id='He26q'></ul>

        <legend id='He26q'><style id='He26q'><dir id='He26q'><q id='He26q'></q></dir></style></legend>
      1. 从不同版本的tf.keras加载保存的模型

        Loading the saved models from tf.keras in different versions(从不同版本的tf.keras加载保存的模型)
          <bdo id='8t91L'></bdo><ul id='8t91L'></ul>
              1. <i id='8t91L'><tr id='8t91L'><dt id='8t91L'><q id='8t91L'><span id='8t91L'><b id='8t91L'><form id='8t91L'><ins id='8t91L'></ins><ul id='8t91L'></ul><sub id='8t91L'></sub></form><legend id='8t91L'></legend><bdo id='8t91L'><pre id='8t91L'><center id='8t91L'></center></pre></bdo></b><th id='8t91L'></th></span></q></dt></tr></i><div id='8t91L'><tfoot id='8t91L'></tfoot><dl id='8t91L'><fieldset id='8t91L'></fieldset></dl></div>

                  <legend id='8t91L'><style id='8t91L'><dir id='8t91L'><q id='8t91L'></q></dir></style></legend>
                  <tfoot id='8t91L'></tfoot>

                    <tbody id='8t91L'></tbody>

                  <small id='8t91L'></small><noframes id='8t91L'>

                1. 本文介绍了从不同版本的tf.keras加载保存的模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在Google CoLab中使用TensorFlow和Kera创建了一个图像分类模型。它分别与GPU版本1.15和2.2.4一起保存在那里。现在我想在我的远程机器上加载CPU和1.10和2.2.2版本,我无法做到这一点,而且出错了。这是我第一次使用CNN以及TF和KERAS,所以我不能找出确切的原因和如何解决这个问题。我已经在下面提到了代码和错误:

                  import tensorflow as tf
                  from tensorflow import keras
                  from tensorflow.keras.models import load_model
                  from tensorflow.keras.models import model_from_json
                  
                  json_file = open('model.json', 'r')
                  loaded_model_json = json_file.read()
                  json_file.close()
                  loaded_model = model_from_json(loaded_model_json)
                  

                  错误: ValueError:(‘无法识别的关键字参数:’,DICT_KEYS([‘RAGG’]))

                  推荐答案

                  TensorFlow1.15包含像粗糙张量支持这样的突破性更改,因此它不支持向后兼容(TF1.10)。这就是问题所在。请尝试使用TensorFlow 1.15加载它,它应该可以工作。

                  You can load tf1.15+ model using tf1.15-2.1. Then save only weights to open in tf1.10
                  ___________________________________________________________________
                  # In tensorflow 1.15-2.1
                  # Load model
                  model = load_model("my_model.h5")
                  
                  # Save weights and architecture
                  model.save_weights("weights_only.h5")
                  
                  # Save model config
                  json_config = model.to_json()
                  with open('model_config.json', 'w') as json_file:
                  json_file.write(json_config)
                  ___________________________________________________________________
                  # In tensorflow 1.10
                  # Reload the model from the 2 files we saved
                  with open('model_config.json') as json_file:
                  json_config = json_file.read()
                  new_model = tf.keras.models.model_from_json(json_config)
                  
                  # Load weights
                  new_model.load_weights('weights_only.h5')
                  

                  您可以参考该链接以更好地了解LINK

                  这篇关于从不同版本的tf.keras加载保存的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                    <small id='3wYQI'></small><noframes id='3wYQI'>

                    <tfoot id='3wYQI'></tfoot>
                  • <legend id='3wYQI'><style id='3wYQI'><dir id='3wYQI'><q id='3wYQI'></q></dir></style></legend>
                  • <i id='3wYQI'><tr id='3wYQI'><dt id='3wYQI'><q id='3wYQI'><span id='3wYQI'><b id='3wYQI'><form id='3wYQI'><ins id='3wYQI'></ins><ul id='3wYQI'></ul><sub id='3wYQI'></sub></form><legend id='3wYQI'></legend><bdo id='3wYQI'><pre id='3wYQI'><center id='3wYQI'></center></pre></bdo></b><th id='3wYQI'></th></span></q></dt></tr></i><div id='3wYQI'><tfoot id='3wYQI'></tfoot><dl id='3wYQI'><fieldset id='3wYQI'></fieldset></dl></div>
                      <tbody id='3wYQI'></tbody>

                        • <bdo id='3wYQI'></bdo><ul id='3wYQI'></ul>