- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在训练过程之后,我想通过加载创建的 model.h5
并执行评估过程来检查准确性。但是,我收到以下警告:
/usr/local/lib/python3.5/dist-packages/keras/engine/saving.py:269: UserWarning: No training configuration found in save file: the model was not compiled. Compile it manually. warnings.warn('No training configuration found in save file:
这个dist-packages/keras/engine/saving.py
文件
所以加载创建模型的问题->这行代码
train_model = load_model('model.h5')
问题表明模型没有编译,但是我编译了。
optimizer = Adam(lr=lr, clipnorm=0.001)
train_model.compile(loss=dummy_loss, optimizer=optimizer)
我不明白我做错了什么。 . .请帮我!紧急求救:-(
最佳答案
我想补充 olejorgenb 的回答 - 对于特定场景,您不想训练模型,只需使用它(例如在生产中)。
“编译”的意思是“准备训练”,主要包括设置优化器。也可以之前保存过,然后载入保存的模型就可以继续“同样”的训练了。
但是,场景如何 - 我只想运行模型?好吧,像这样使用 compile=False
参数到 load_model
:
trained_model = load_model('model.h5', compile=False)
如果不首先使用 trained_model.compile(...)
,您将无法.fit()
这个模型,但最重要的是 - 警告将会消失离开。
顺便说一句,在我的 Keras 版本中,参数 include_optimizer
的默认值为 True
。这也适用于 Checkpoint
等训练回调。这意味着,在加载由 Keras 保存的模型时,您通常可以指望包含优化器(情况除外:请参阅 Hull Gasper 的回答)。
但是,当您有一个未经 Keras 训练的模型时(例如,当转换一个由 Darknet 训练的模型时),该模型将以未编译的方式保存。这会产生警告,您可以按照上述方式摆脱它。
关于python - UserWarning : No training configuration found in save file: the model was *not* compiled. 手动编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53295570/
我用的是“tab10”调色板,因为它的颜色是蓝色、绿色、橙色和红色。。簇的数量只有4个,调色板“tab10”有4种以上的颜色。有没有办法解决这个用户警告问题?。输出为:
我用的是“tab10”调色板,因为它的颜色是蓝色、绿色、橙色和红色。。簇的数量只有4个,调色板“tab10”有4种以上的颜色。有没有办法解决这个用户警告问题?。输出为:
从 matplotlib 收到此警告,我尝试设置 fmt,但它对我不起作用(也许做错了)。我确实抑制了警告并且它起作用了,但我不想抑制所有 python 警告,因为我认为这应该可以解决。谢谢你的帮助。
我使用 openpyxl 来解析 .xlsm 文件,并使用 pytest 进行测试。 当我打开文件时,我得到: OpenPyxl -> UserWarning:不支持数据验证扩展,将被删除 这并不是真
我使用带有密码管理器的开启器,当我第一次使用我的开启器时,我收到了以下警告消息: /usr/lib/python2.7/urllib2.py:894: UserWarning: Basic Auth
运行命令 dataframe['geometry'].centroid显示警告: 列“几何”由多多边形对象组成。如何解决此问题以准确计算多多边形形状的质心? 最佳答案 这个错误可以通过投影来解决这个问
这个问题在这里已经有了答案: Python: UserWarning: This pattern has match groups. To actually get the groups, use
假设我有类似这样的代码: import pandas as pd df=pd.DataFrame({'Name': [ 'Jay Leno', 'JayLin', 'Jay-Jameson', 'Li
在命令行中运行大多数 python 脚本时会收到以下类型的警告: /Library/Python/2.6/site-packages/virtualenvwrapper/hook_loader.py:
安装 Google Cloud Bigquery 模块后,如果我将该模块导入 python 代码。我看到这条警告消息。在 python 3.7.3 Virtualenv 中发生在我身上。 尝试重新安装
当我用另一组数据屏蔽我的数据集时,它会显示用户警告: bool 系列键将被重新索引以匹配 DataFrame 索引。我该如何避免这种情况? Python 会自动重新索引它,但该列的标题是空白的,我似乎
我正在尝试学习 Python(第 2 天),并希望首先使用 Excel 书籍进行练习,因为这是我感到舒适/流利的地方。 在运行以下代码时,我立即遇到了一个我无法理解的错误: import openpy
尝试使用 python matplotlib 绘制图形:但不断收到以下警告消息: "UserWaring: tight_layout: falling back to Agg renderer wa
当我使用 pip 将东西安装到 virtualenv 中时,我经常看到消息“UserWarning: Unbuilt egg for setuptools”。我总是安全地忽略它并继续我的业务,它似
给定以下 pandas DataFrame - json_path报告组实体/分组实体 ID调整后值(value)(今天,无股息,美元)调整后的 TWR(当前季度,无股息,美元)调整后的 TWR(年初
我正在尝试运行来自 official website 的基本 matplotlib 示例: 但是,当我运行代码时,我的 Python 解释器会报错并输出以下消息: UserWarning: Matpl
我正在尝试运行来自 official website 的基本 matplotlib 示例: 但是,当我运行代码时,我的 Python 解释器会报错并输出以下消息: UserWarning: Matpl
在 pytest 中断言 UserWarning 和 SystemExit 在我的应用程序中,我有一个函数,当提供错误的参数值时,将从 warnings 模块中引发一个 UserWarnings,然后
下面是我的多图像分类代码。我收到错误;我认为这是因为加载和其他地方尺寸不匹配。 错误消息从代码结束处开始。有人能看出问题所在吗? #importing necessary packages impor
我有一个数据框,我尝试获取字符串,其中列中包含一些字符串Df 看起来像 member_id,event_path,event_time,event_duration 30595,"2016-03-30
我是一名优秀的程序员,十分优秀!