UserWarning:'lr'参数已弃用,请使用'learning\u rate'`

2024-09-28 05:17:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用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)


Tags: the代码警告rateisusetensorflowargument
1条回答
网友
1楼 · 发布于 2024-09-28 05:17:55

这似乎是使用旧参数名的包的问题。这只是一个警告,因此代码仍将正常运行

更新包时,警告将消失

同时,要忽略警告,请运行带有-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()

相关问题 更多 >

    热门问题