简体   繁体   English

在 pycharm 上加载经过训练的 Tensorflow 保存模型时出错。 ValueError:int() 的无效文字,基数为 10:'class_name'

[英]Error while loading trained Tensorflow Saved Model on pycharm. ValueError: invalid literal for int() with base 10: 'class_name'

Context: I have trained a model which consist in an image classifier.This model consist in a TF CNN and has been trained online (with google colaboratory) I then downloaded it as a tf.savemodel object.背景:我已经训练了一个包含在图像分类器中的模型。这个模型包含在一个 TF CNN 中并且已经在线训练(与谷歌合作)然后我将它下载为一个 tf.savemodel 对象。 I would like to deploy this trained model on a PyQt5 Desktop app.我想在 PyQt5 桌面应用程序上部署这个训练有素的模型。

Problem: When I try to load my trained model in my code in PyCharm (2020.1.3) I get the following error :问题:当我尝试在 PyCharm (2020.1.3) 的代码中加载经过训练的模型时,出现以下错误:

ValueError: invalid literal for int() with base 10: 'class_name'

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又出现了一个异常:

ValueError: Error converting shape to a TensorShape: invalid literal
for int() with base 10: 'class_name'.

code used to load model:用于加载模型的代码:

model1=tf.keras.models.load_model(r'C:\Users\user\Desktop\UNI\L3\saved_models\model7')

SIDE NOTE: When I run the same line on colab the model is successfully loaded into the notebook.旁注:当我在 colab 上运行同一行时,模型已成功加载到笔记本中。

Questions:问题:
-What does the error mean? - 错误是什么意思?
-Why does it work on colab and not in my IDE? - 为什么它可以在 colab 上运行,而不是在我的 IDE 中?
-How can I fix this in order to load and use the trained model in my app ? - 我该如何解决这个问题,以便在我的应用程序中加载和使用经过训练的模型?

  1. Works on colab but not on IDE because you have different version of tenserflow installed at both postion适用于 colab 但不适用于 IDE,因为您在两个位置都安装了不同版本的tenserflow
  2. Changing Tensorflow version from 2.0.0 to 2.3.1 solve the issue.将 TensorFlow 版本从 2.0.0 更改为 2.3.1 解决了这个问题。

检查当前系统中 TF 的版本,您可能已经使用 2.1 进行了训练,并尝试使用 2.3 版本加载模型

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ValueError:tensorflow中以10为底的int()的无效文字 - ValueError: invalid literal for int() with base 10 in tensorflow 获取错误“ ValueError:int()的无效文字,基数为10:'3128;' 在运行Tensorflow训练示例时 - Getting an error "ValueError: invalid literal for int() with base 10: '3128;' while running the Tensorflow training example 错误 - ValueError:基数为10的int()的文字无效:'' - Error - ValueError: invalid literal for int() with base 10: ' ' 错误:ValueError:int()以10为底的无效文字: - Error: ValueError: invalid literal for int() with base 10: '' ValueError:int() 的无效文字,基数为 10:'' 错误 - ValueError: invalid literal for int() with base 10: '' error 深度学习 model:ValueError:int() 的无效文字,基数为 10:'php' - Deep learning model : ValueError: invalid literal for int() with base 10: 'php' Tensorflow 从源错误 ValueError 构建:在 cuda 路径配置期间 int() 以 10 为基数的无效文字:''? - Tensorflow build from source error ValueError: invalid literal for int() with base 10: '' during cuda path configuration? {ValueError: invalid literal for int() with base 10:} 对整数进行分组时 - {ValueError: invalid literal for int() with base 10:} While Grouping Integers ValueError:从自定义用户模型创建用户对象时,以int()为基数为10的int()无效文字:“ glassdoor” - ValueError: invalid literal for int() with base 10: 'glassdoor' while creating a user object from custom user model valueError:迁移时int()以10为底的无效文字:``'' - valueError: invalid literal for int() with base 10: '' while migrate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM