python - 用户警告:不推荐使用“lr”参数,请使用“learning_rate”
问题描述
我正在尝试使用 textgenrnn 训练神经网络,但是当我运行代码时,它会立即给我一个警告UserWarning: The lr argument is deprecated, use learning_rate
我该如何解决这个“问题”?
代码
from textgenrnn import textgenrnn
textgen = textgenrnn()
textgen.train_from_file('my_file.txt', num_epochs=1)
textgen.generate()
警告
/Users/username/Documents/Develop/Neural2/venv/lib/python3.8/site-packages/tensorflow/python/keras/optimizer_v2/optimizer_v2.py:375: UserWarning: The `lr` argument is deprecated, use `learning_rate` instead.
warnings.warn(
2021-08-04 00:34:58.301349: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
76 texts collected.
Training on 1,374 character sequences.
2021-08-04 00:34:58.861705: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2)
解决方案
这似乎是使用旧参数名称的包的问题。这只是一个警告,所以代码仍然会正常运行。
更新包后警告将消失。
同时,要忽略警告运行带有 -W 标志的文件。
python -W ignore::DeprecationWarning file.py
或者导入警告模块并在代码中捕获警告。
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
textgen = textgenrnn()
textgen.train_from_file('my_file.txt', num_epochs=1)
textgen.generate()
推荐阅读
- rust - Rust 中是否有任何机制等效于没有虚拟(动态调度)的 C++ 继承?
- vue.js - 如何在具有多个过滤器的 v-data-table 中选择默认值
- node.js - 在使用 Angular 应用程序运行 Lighthouse 后注册一个卸载侦听器
- reactjs - 如何在使用反应选择后过滤值重置 - 管理员
- c++ - std::partition 实现
- python - Python OS For Loop - TypeError:“模块”对象不可调用
- c++ - C ++中的GFG括号检查器问题给出错误答案
- powershell - 添加没有“用户下次登录时必须更改密码”的新本地用户
- sql-server - 索引匹配模式到任何数字
- linux - 如何从 PLINK 2.0 上的剂量文件创建 MAP/PED 文件