Use of PyYAML's yaml.load function without specifying the Loader=... parameter, has been deprecated.

用keras函数model_from_yaml时会触发警告崩溃,崩溃是因为使用YAML 5.1版本导致的,崩溃如下:

错误:Use of PyYAML's yaml.load function without specifying the Loader=... parameter, has been deprecated. 

触发原因:YAML 5.1版本不支持keras\engine\saving.py行437:config = yaml.load(yaml_string),

解决:

1)需要修改为:config = yaml.load(yaml_string, Loader=yaml.FullLoader)。这个仅限YAML 5.1。

2)修改环境变量消除警告 PYTHONWARNINGS=ignore::yaml.YAMLLoadWarning

3)或者降YAML版本,pip install pyYAML==3.13

Ref:

https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation

If you are simply using Python software that issues the "load() deprecation" warning, you should notify the authors of that software about it, so they can make and release the proper adjustments. One way to control/disable the warning is with the PYTHONWARNINGS environment variable:

PYTHONWARNINGS=ignore::yaml.YAMLLoadWarning

You can read more about PYTHONWARNINGS here.

If you are the author/maintainer of the Python code that is triggering the warning, the best way to stop getting the warning is to specify the Loader= argument like so:

yaml.load(input, Loader=yaml.FullLoader)

你可能感兴趣的:(掉过的坑,AI/ML/DL)